08 2011 档案

摘要:#include"iostream"#include"cstdio"#include"cstring"using namespace std;int N,num[200005];int main(){ while(scanf("%d",&N),N) { int res=0; for(int i=0;i<N;++i) scanf("%d",&num[i]),res^=num[i]; if(res==0) puts("No"); else { puts(&q 阅读全文
posted @ 2011-08-28 11:01 bcy 阅读(213) 评论(0) 推荐(0)
摘要:#include"iostream"#include"cstdio"using namespace std;int num[1000005],n;int main(){ while(scanf("%d",&n),n) { int s=0,temp,res=0; for(int i=0;i<n;++i) scanf("%d",&num[i]),res^=num[i]; if(res==0) puts("0"); else { for(int i=0;i<n;++i) { 阅读全文
posted @ 2011-08-28 10:07 bcy 阅读(196) 评论(0) 推荐(0)
摘要:#include"stdio.h"int main(){ int n,m,t; scanf("%d",&t); while(t--&&scanf("%d%d",&n,&m)) puts(n%(m+1)?"first":"second"); return 0; } 这是一个巴什博弈的题目,要想让第二个人赢,只有当(m+1)是n的因子时才成立,所以直接puts就可以了。 阅读全文
posted @ 2011-08-19 21:54 bcy 阅读(125) 评论(0) 推荐(0)
摘要:题意:求两个大数的和;(注意输出格式)#include"stdio.h"#include"string.h"int shu(char a){ return (a-'0');}int main(){ char a[1000],b[1000]; int num[1001]; int n,i,j=1,al,bl,k,t; scanf("%d",&n); while(n--) { getchar(); if(j!=1) printf("\n"); scanf("%s",& 阅读全文
posted @ 2011-08-15 10:55 bcy 阅读(104) 评论(0) 推荐(0)
摘要:题意:求前某项的和最大#include"stdio.h"#define min -99999999int sta,end;int main(){ int n,i,j,t,sum,maxsum,in,b; scanf("%d",&n); for(i=0;i<n;i++) { sum=0;maxsum=min;sta=0; scanf("%d",&t); for(b=j=0;j<t;j++) { scanf("%d",&in); sum+=in; if(sum>maxsum) 阅读全文
posted @ 2011-08-14 21:06 bcy 阅读(164) 评论(0) 推荐(0)
摘要:#include <stdio.h>main(){ int n; for(n=2000;n<=2500;n++) if(n%4==0&&n%100!=0||n%400==0) printf("%d是闰年\n",n); else printf("%d不是闰年\n",n);}#include <stdio.h>main(){ int m,n; for(m=1,n=2;n<=5;n++) { m*=n; } printf("%d\n",m); 阅读全文
posted @ 2011-08-11 17:24 bcy 阅读(188) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<math.h>#define L 10void conversion(int N,int r){ int s[L],top; int x; top=-1; while(N) { s[++top]=N%r; N=N/r; } while(top!=-1) { x=s[top--]; printf("%d\n",x); } printf("\n");}main(){ int N,r; scanf("%d%d",&N,&r);conversion(N 阅读全文
posted @ 2011-08-11 17:19 bcy 阅读(166) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>#include<stdlib.h>int N, M, set[1010];int find ( int x ) { return x==set[x]?x:set[x]= find ( set[x] ); }void Union ( int x, int y ) { int a = find (x), b = find(y); if ( a != b ) { set[a] = b; } }int main () { int a, b, x, y, sum; while ( scanf ( 阅读全文
posted @ 2011-08-11 17:17 bcy 阅读(140) 评论(0) 推荐(0)
摘要:void Swap(int& x,int& y){int temp = x;x = y;y = temp;}void quicksort(int array[], int left, int right) {//快速排序的函数(以中间的数为标准) int i, j, s; if(left < right) { s = array[(left+right)/2]; i = left - 1; j = right + 1; while(1) { while(array[++i] < s) ; while(array[--j] > s) ; if(i >= j 阅读全文
posted @ 2011-08-11 17:16 bcy 阅读(209) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>#include<stdlib.h>int N, M, map[1010][1010], dis[1010], hash[1010], cnt, dp[1010];const int inf = 0x7fffffff;void Dijsktra () { dis[2] = 0; for ( int i = 1; i <= N; i++ ) { int pos, t = inf; for ( int j = 1; j <= N; j++ ) { if ( hash[j] == 0 阅读全文
posted @ 2011-08-11 17:16 bcy 阅读(147) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>const int inf = 0x7fffffff;int st[110], rank[110], N, M, x, y, val, maxN, map[110][110];struct Edge { int x, y, val;}e[10000];int cmp ( const void *a, const void *b ) { return (( Edge * )a)->val - ( ( Edge * )b )->val; } 阅读全文
posted @ 2011-08-11 17:15 bcy 阅读(186) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>struct T { T * ch[26]; int n, flag;}rt;char in[15];void init ( T * t ) { for ( int i = 0; i < 26; ++ i ) t->ch[i] = NULL; t->n = t->flag = 0;}void insert ( T *t, char *in ) { if ( *in ) { if ( t->ch[ *in - ' 阅读全文
posted @ 2011-08-11 17:14 bcy 阅读(130) 评论(0) 推荐(0)
摘要:#include<stdio.h>int n,m,map[124][124];int inf = 0x7fffffff;void floyd( ){ for( int i = 1; i <= n; ++i ) for( int j = 1; j <= n; ++j ) for( int k = 1; k <= n; ++k ) if( map[i][j] != inf && map[i][k] != inf ) if( map[i][j] + map[i][k] < map[j][k] ) map[j][k] = map[i][j] + ma 阅读全文
posted @ 2011-08-11 17:14 bcy 阅读(128) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>int set[100000],b[100000];int find(int x){return (x==set[x])?x:set[x]=find(set[x]);}int main(){ int n,x,y,max,X,Y; while(scanf("%d",&n)!=EOF){ for(int i=0;i<100000;i++) { set[i]=i;b[i]=1; } for( int i=0;i<n;i++){ scanf("%d%d&quo 阅读全文
posted @ 2011-08-11 17:13 bcy 阅读(161) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>#include<string.h>int n,m,num[100024];int cmp( const void *a,const void *b ){ return *( int * )b - *( int * )a;}int main( ){ while( scanf( "%d%d",&n,&m ) , n | m ) { for( int i = 0; i < n; ++i ) scanf( "%d",&num[ 阅读全文
posted @ 2011-08-11 17:12 bcy 阅读(152) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>#include<string.h>char s1[15], s2[15];long long int abc ( char *s ) {long long int sum;int length = strlen ( s );for ( int i = 0; i < length; i++ ) { if ( s[i] == ',' ) {for ( int j = i; j < length-1 ; j++ ) { s[j] = s[j+1];} s[lengt 阅读全文
posted @ 2011-08-11 17:11 bcy 阅读(167) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>#define MAXSIZE 100000typedef int DataType;typedef struct{DataType data[MAXSIZE];int last;}Seqlist;Seqlist *L;void init_Seqlist(){L=(Seqlist *)malloc(sizeof(Seqlist));L->last=-1;}void va(){ int t; for(int i=0;i<=L->last/2;i++){t= L->data[i]; 阅读全文
posted @ 2011-08-11 17:10 bcy 阅读(184) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<iostream.h>#define MAXSIZE 1024typedef char DataType;typedef struct{ DataType data[MAXSIZE]; int top;}SeqStack;SeqStack *s;SeqStack *Init_SeqStack(){ SeqStack *s; s=new SeqStack; if(!s) { printf("空间不足\n");return NULL; } else { s->top=-1;return s; }} 阅读全文
posted @ 2011-08-11 17:09 bcy 阅读(180) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<iostream.h>#define MAX 1000typedef int DataTypetypedef struct{ DataType data[MAX];int last;}SeqList;int Delete_SeqList(SeqList * L){ int i,j,k; DataType temp; for(i=1;i<=L->last;i++) { temp=L->last; for(j=2;j<=L->last;j++) { if(temp=L->last[j]) 阅读全文
posted @ 2011-08-11 17:08 bcy 阅读(318) 评论(0) 推荐(0)
摘要:#include<stdio.h >#include<malloc.h>#define OK 1#define ERROR 0typedef struct BiTNode{char data;struct BiTNode *lChild,*rChild;}BiTNode,*BiTree;//二叉树的初始化函数int Initiate(BiTree bt)//二叉树的头结点 { bt = (BiTree )malloc(sizeof(BiTNode)); if(bt==NULL) return 0; bt->lChild=NULL; bt->rChild=NU 阅读全文
posted @ 2011-08-11 17:07 bcy 阅读(773) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>typedef struct tree{ int num; struct tree *lchild,*rchild;}tree;tree *creatree(){ int num; tree *T; scanf("%d",&num); if(num==0) T=NULL; else { T=(tree*)malloc(sizeof(tree)); T->num=num; T->lchild=creatree(); T->rchild=creatree(); 阅读全文
posted @ 2011-08-11 17:06 bcy 阅读(224) 评论(0) 推荐(1)
摘要:#include <cstdio>#include <cmath>int N;bool isp(int n){ if( n <= 1 ) return 0; if( n == 2 ) return 1; int i , t = sqrt(n); for(i = 2 ; i <= t ; i++) if(n%i == 0) return 0; return 1;}void dfs(int n, int len){ if(len == N) { printf("%d\n",n); return; } else { int i ; for(i 阅读全文
posted @ 2011-08-11 17:05 bcy 阅读(163) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>int n,num[10000],dis[10000];int cal( ){ int Max = 0; for( int i = 1; i <= n;++i ) { int max = 0,pos = 0; for( int j = 0; j <= i; ++j )//找前面已经存在且符合条件的最优解 if( dis[j] > max && num[j] < num[i] ) max = dis[j]; dis[i] += num[i] + max;//找到后 阅读全文
posted @ 2011-08-11 16:59 bcy 阅读(177) 评论(0) 推荐(0)
摘要:#include"stdio.h"#include"stdlib.h"#include"string.h"#include"math.h"int sushu(int x){ int t=(int)sqrt(x+1); for(int j=2;j<=t;j++) { if(x%j!=0) return 1; else { break; return 0; } }}int main(){ int N,k,cnt,max; while(scanf("%d",&N)!=EOF) { whi 阅读全文
posted @ 2011-08-11 16:56 bcy 阅读(189) 评论(0) 推荐(0)
摘要:#include"stdio.h"#include"stdlib.h"#include"math.h"#include"string.h"double diss(int x1,int x2,int y1,int y2){ int dis=0; return (sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); }int main(){ int x,y,n,map[1010][1010]; double sum[1010]={0},dis[1010]={0}; while(scanf(&q 阅读全文
posted @ 2011-08-11 16:51 bcy 阅读(129) 评论(0) 推荐(0)
摘要:#include"stdio.h"#include"string.h"int map[25][25],des[25][25],n,m,sx,sy;void DFS(int y,int x){ if(map[y][x]=='#'||des[y][x]||y>n||x>m) return ; des[y][x]=1; DFS(y-1,x); DFS(y+1,x); DFS(y,x-1); DFS(y,x+1); }int main(){ while(scanf("%d%d*c",&m,&n),n 阅读全文
posted @ 2011-08-11 16:48 bcy 阅读(169) 评论(0) 推荐(0)
摘要:#include"stdio.h"#include"string.h"#include"stdlib.h"#include"math.h"#define MAXSIZE 10000000int prim[MAXSIZE+5];void fun(){ memset(prim,0,sizeof(prim)); prim[0]=prim[1]=1; for(int i=4;i<=MAXSIZE;i+=2) { prim[i]=1; } double t=sqrt(MAXSIZE); for(int i=3;i< 阅读全文
posted @ 2011-08-11 16:24 bcy 阅读(137) 评论(0) 推荐(0)
摘要:题意:给出N个数,将其中重复出现的去掉,再将新的序列进行排序输出;#include<stdio.h> #include<stdlib.h> int cmp(const void *a, const void *b) { return *(int *)a-*(int *)b; } int main() { int a[101]; int b[101]={0}; int m; int k=0; while(scanf("%d",&m)!=EOF) { int i,j; for(i=0;i<m;i++) scanf("%d" 阅读全文
posted @ 2011-08-11 16:22 bcy 阅读(200) 评论(0) 推荐(0)
摘要:#include"iostream"#include"cstdlib"#include"cmath"using namespace std;const int MAX=1000;int main(){ int i=0,j=0,n=sqrt(MAX)+1; int a[MAX+1]={0}; for(i=2;i<=n;i++) a[j*i]=1; for(i=2;i<=MAX;i++) if(a[i]==0) { cout.width(7); cout<<i<<""; } //sy 阅读全文
posted @ 2011-08-11 16:04 bcy 阅读(127) 评论(0) 推荐(0)
摘要:#include#include#include#includeint gcd(int m,int n){ return n==0?m: gcd(n,m%n);}int main(){ int m,n; while(scanf("%d%d",&m,&n)!=EOF) { printf("%d %d\n",gcd(m,n),((m*n)/gcd(m,n))); getchar(); } return 0;} 阅读全文
posted @ 2011-08-09 18:32 bcy 阅读(131) 评论(0) 推荐(0)
摘要:#include"stdio.h"#define N 13#define M 100005int a[N][M];int b[N][M];int main(){ int i,j; int n; int k; int hl,hm,hr; int max; while(scanf("%d",&n)!=EOF) { if(n==0) return 0; k=0; for(i=0;ihm?hl:hm; max=max>hr?max:hr; a[i][j]=max; } } max=0; for(i=1,j=k;imax) { max=a[i][j] 阅读全文
posted @ 2011-08-09 17:13 bcy 阅读(149) 评论(0) 推荐(0)
摘要:#include"stdio.h"#include"iostream"#include"algorithm"#include"map"using namespace std;int n,k,M;struct Matrix{ void init() { memset(m,0,sizeof(m)); } Matrix operator *(Matrix t) { Matrix t1; t1.init(); for(int i=0;i<n;++i) for(int j=0;j<n;++j) { for(int 阅读全文
posted @ 2011-08-09 11:34 bcy 阅读(298) 评论(0) 推荐(0)
摘要:题意:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。(仍然是最小生成树问题)#include"stdio.h"#include"stdlib.h"struct e{ int x,y,v; }val[10500];int set[105],n,m,sum;int cmp(const void *a,const void *b){ return (( 阅读全文
posted @ 2011-08-08 16:26 bcy 阅读(170) 评论(0) 推荐(0)
摘要:本题求的是最小生成树,Kustra(或prim)算法。快排时用qsort,不用冒泡(可能会超时);题意:使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Kustra算法求解:#include"stdio.h"#include"stdlib.h"int set[105],n,m,sum;struct e{ int x,y,v; }val[10000];int cmp(const void *a,const void *b){ return ((e *)a) 阅读全文
posted @ 2011-08-08 11:28 bcy 阅读(180) 评论(0) 推荐(0)
摘要:问题描述如下:“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? 城镇数码N,道路数目M;简单的畅通工程,只要套模板就OK 。不过要理解哦。。。(若有N个集合,则最少只需N-1条道路就可以连起来)#include"stdio.h"int set[1024];int find(int i){ return set[i]==i?set[i]:find(set[i]); }void merge(int x,int y){ int a=find(x),b=find(y); set[a]=b; 阅读全文
posted @ 2011-08-05 22:27 bcy 阅读(153) 评论(0) 推荐(0)
摘要:不容易系列之一 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6540Accepted Submission(s): 2719Problem Description大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样。话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的。比如,我高中的时候,就有一个神奇的女生,在英语. 阅读全文
posted @ 2011-08-05 21:46 bcy 阅读(146) 评论(0) 推荐(0)
摘要:#include"iostream"using namespace std;int c1[250010],c2[250010];int value[55];int amount[55];int main(){ int nNum; while(scanf("%d",&nNum)&&nNum>0) { memset(value,0,sizeof(value)); memset(amount,0,sizeof(amount)); int sum=0; for(int i=1;i<=nNum;++i) { scanf(&quo 阅读全文
posted @ 2011-08-05 12:10 bcy 阅读(231) 评论(0) 推荐(0)
摘要:输入1分,2分,5分的硬币,输出不能组成的最小总值;#include"iostream"using namespace std;int c1[10000],c2[10000];int num[4];int main(){ int nNum; while(scanf("%d %d %d",&num[1],&num[2],&num[3])&&(num[1]||num[2]||num[3])) { int _max=num[1]*1+num[2]*2+num[3]*5; for(int i=0;i<=_max;++ 阅读全文
posted @ 2011-08-05 10:50 bcy 阅读(229) 评论(0) 推荐(0)
摘要:Square Coins#include"iostream"using namespace std;int c1[310],c2[310];int main(){ int i,j,k,nNum; while(scanf("%d",&nNum),nNum) { for(i=0;i<=nNum;++i) { c1[i]=1; c2[i]=0; } for(i=2;i*i<=nNum;++i)//注意i和k处有所改动; { for(j=0;j<=nNum;++j) for(k=0;k+j<=nNum;k+=i*i) c2[k+j 阅读全文
posted @ 2011-08-04 22:20 bcy 阅读(213) 评论(0) 推荐(0)
摘要:Problem BTime Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 142Accepted Submission(s) : 44Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!"人们纷纷来到告示 阅读全文
posted @ 2011-08-04 17:34 bcy 阅读(161) 评论(0) 推荐(0)
摘要:Problem ATime Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 154Accepted Submission(s) : 58Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description完数的定义:如果一个大于1的正整数的所有因子之和等于它的本身,则称这个数是完数,比如6,28都是完数:6=1+2+3;28=1+2+4+7+14。本题的任务是判断两个正整数之间 阅读全文
posted @ 2011-08-04 17:31 bcy 阅读(208) 评论(0) 推荐(0)
摘要:#include<iostream>#include<cstdlib>#include<cmath>#include<cstdio>#include<cstring>#include<algorithm>#include<map>using namespace std;int cnt = 0;char hash[10000];map<string,int> q;struct e{char ch[1000];}E[10005];void read( char str[] ){int i = 0;cha 阅读全文
posted @ 2011-08-04 17:12 bcy 阅读(163) 评论(0) 推荐(0)
摘要:描述:输入N,求解有几种和式;#include"iostream"using namespace std;int c1[130],c2[130];int main(){ int N; int i,j,k; while(scanf("%d",&N)!=EOF) { for(i=0;i<=N;++i) { c1[i]=1; c2[i]-0; } for(i=2;i<=N;++i) { for(j=0;j<=N;++j) for(k=0;k+j<=N;k+=i) c2[j+k]+=c1[j]; for(j=0;j<=N;+ 阅读全文
posted @ 2011-08-04 16:08 bcy 阅读(152) 评论(0) 推荐(0)
摘要:有1克、2克、3克、4克的砝码各一枚,能称出哪几种重量?各种重量各有几种可能方案?考虑用母函数来求解:G(x)=(1+x+x^2+x^3…)*(1+x^2+x^4+…)*(1+x^3+x^6+…)#include"iostream"using namespace std;const int _max=10001;int c1[_max],c2[_max];//c1是保存各项质量砝码可以组合的数目;c2是中间量,保存每一次的情况;int main(){ int nNum; int i,j,k; while(cin>>nNum) { for(i=0;i<=nN 阅读全文
posted @ 2011-08-04 10:35 bcy 阅读(219) 评论(0) 推荐(0)
摘要:#include"stdio.h"int n,dis[100000],max,dp[100000];void DP(){ for(int i=1;i<=n;++i) { dp[i]=1; for(int j=1;j<i;++j) if(dis[i]>dis[j]&&dp[j]+1>dp[i]) dp[i]=dp[j]+1; if(dp[i]>dp[max]) max=i; } }int main(){ int t; while(scanf("%d",&n)!=EOF) { max=0; dis[0]= 阅读全文
posted @ 2011-08-02 22:08 bcy 阅读(126) 评论(0) 推荐(0)
摘要:Problem B: 素因子Time Limit: 5 SecMemory Limit: 128 MBSubmit: 266Solved: 113[Submit][Status][Web Board]Description我们知道,任何一个大于1的数,都可以写成多个素数的乘积,我们把这些素数叫做这个数的素因子。Input第一行为测试数据的组数N,以下N行,每行一个数字k(1<k<2^24)Output输出N行,每行两个数字,一个是k的最大素因子,第二个是k的素因子的个数。Sample Input31025120Sample Output5 2#include"stdio. 阅读全文
posted @ 2011-08-02 10:54 bcy 阅读(387) 评论(0) 推荐(0)
摘要:Problem G: 子网掩码Time Limit: 1 SecMemory Limit: 128 MBSubmit: 40Solved: 23[Submit][Status][Web Board]Description子网掩码计算方法 子网掩码是用来判断任意两台计算机的IP地址是否属于同一子网络的根据。最为简单的理解就是两台计算机各自的IP地址与子网掩码进行AND运算后,如果得出的结果是相同的,则说明这两台计算机是处于同一个子网络上的,可以进行直接的通讯。就这么简单。请看以下示例:运算演示之一:aa I P 地址 192.168.0.1 子网掩码 255.255.255.0 AND运算转化为 阅读全文
posted @ 2011-08-01 21:59 bcy 阅读(291) 评论(0) 推荐(0)
摘要:Problem F: 不高兴的津津Time Limit: 1 SecMemory Limit: 128 MBSubmit: 43Solved: 27[Submit][Status][Web Board]Description津津上初中了。妈妈认为津津应该更加用功学习,所以津津除了上学之外,还要参加妈妈为她报名的各科复习班。另外每周妈妈还会送她去学习朗诵、舞蹈和钢琴。但是津津如果一天上课超过八个小时就会不高兴,而且上得越久就会越不高兴。假设津津不会因为其它事不高兴,并且她的不高兴不会持续到第二天。请你帮忙检查一下津津下周的日程安排,看看下周她会不会不高兴;如果会的话,哪天最不高兴。Input输入 阅读全文
posted @ 2011-08-01 20:57 bcy 阅读(313) 评论(0) 推荐(0)
摘要:Problem E: 级数求和Time Limit: 1 SecMemory Limit: 128 MBSubmit: 55Solved: 26[Submit][Status][Web Board]Description已知:Sn= 1+1/2+1/3+…+1/n。显然对于任意一个整数K,当n足够大的时候,Sn大于K。现给出一个整数K(1<=k<=15),要求计算出一个最小的n;使得Sn>K。Input键盘输入 kOutput屏幕输出 nSample Input1Sample Output2////////////////////#include"stdio.h" 阅读全文
posted @ 2011-08-01 20:56 bcy 阅读(224) 评论(0) 推荐(0)
摘要:#include"stdio.h"int a[1005][1005];bool used[1005];int dis[1005];int main(){ int t,n,i,j,k,x,y,s,tmin; for(i=0;i<1005;i++) for(j=0;j<1005;j++) a[i][j]=99999999; for(i=0;i<1005;i++) { used[i]=0; a[i][i]=0; dis[i]=99999999; } scanf("%d %d",&t,&n); for(i=0;i<t;i+ 阅读全文
posted @ 2011-08-01 15:53 bcy 阅读(147) 评论(0) 推荐(0)