2012年8月2日

HDU 3782 -Dragon Ball

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n,count; 6 while(scanf("%d",&n)&&n!=0) 7 { 8 count=0; 9 while(n>1)10 {11 if(n&1) n=(n*3+1)>>1;12 else n>>=1;13 count++;14 }15 printf("%d\n",count);16 }17 ... 阅读全文

posted @ 2012-08-02 16:47 mycapple 阅读(193) 评论(0) 推荐(0)

HDU 2222- Keywords Search

摘要: 1 //一般方法 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<string.h> 5 char a[10001][51],b[10000001]; 6 int main() 7 { 8 int i,j,k,la,lb,m,n,count; 9 scanf("%d",&m);10 while(m--)11 {12 for(scanf("%d",&n),count=i=0;i<n;++i)13 scanf("%s",a[i 阅读全文

posted @ 2012-08-02 16:46 mycapple 阅读(186) 评论(0) 推荐(0)

HDU 1877 -又一版A+B

摘要: 1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int m,a,b,sum; 6 char ch[50]; 7 while(cin>>m>>a>>b,m) 8 { 9 sum=a+b;10 itoa(sum,ch,m); // 把一整数转换为字符串,即将sum转换为m进制数,,返回到ch字符串 11 cout<<ch<<endl;12 }13 return 0;14 }15 阅读全文

posted @ 2012-08-02 16:45 mycapple 阅读(200) 评论(0) 推荐(0)

HDU 2115 -I Love This Game

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h>//包含qsort函数的头文件 4 struct node 5 { 6 char name[20],time[6]; 7 int t;//时间 8 int rank;//排名 9 }p[11];10 int cmp(const void *a,const void *b)11 {12 struct node *c=(struct node *)a;13 struct node *d=(struct node *)b;14 ... 阅读全文

posted @ 2012-08-02 16:45 mycapple 阅读(230) 评论(0) 推荐(0)

HDU 1234- 开门人和关门人

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 struct point 4 { 5 char s1[20],s2[20],s3[20]; 6 }p[1000005];//定义结构体数组 7 int main() 8 { 9 int N,M,i;10 scanf("%d",&N);11 while(N--)12 {13 scanf("%d",&M);14 for(i=0;i<M;i++)15 scanf("%s%s%s",p[i].s1,p[i].s2 阅读全文

posted @ 2012-08-02 16:44 mycapple 阅读(208) 评论(0) 推荐(0)

HDU 1229- 还是A+B

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int a,b,k,s; 6 while(scanf("%d%d%d",&a,&b,&k)) 7 { 8 if(a==0&&b==0) 9 break;10 s=pow(10.0,k); //计算x的y次幂,x应大于零,返回幂指数的结果11 if(a%s==b%s)12 printf("-1\n");13 else printf("%d\n",a+b);14 阅读全文

posted @ 2012-08-02 16:43 mycapple 阅读(233) 评论(0) 推荐(0)

HDU 1076 An Easy Task

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int year,y,m,n,count; 6 scanf("%d",&n); 7 while(n--) 8 { 9 count=0;10 scanf("%d%d",&y,&m);11 for(year=y;;year++)12 {13 if((year%4==0&&year%100!=0)||(year%400)==0)14 c... 阅读全文

posted @ 2012-08-02 16:42 mycapple 阅读(320) 评论(0) 推荐(0)

HDU 1201 18岁的生日

摘要: 1 #include<iostream> 2 using namespace std; 3 bool rn(int year) //bool为布尔型,只有一个字节,取值false和true,是0和1的区别 4 { 5 if(year%4==0&&year%100!=0||year%400==0) 6 return true; 7 else 8 return false; 9 }10 int main()11 {12 int y,m,d,n,k;13 char c;14 cin>>n;15 wh... 阅读全文

posted @ 2012-08-02 16:42 mycapple 阅读(265) 评论(0) 推荐(0)

HDU 1004 Let the Balloon Rise

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int i,j,t[1001],n,max; 6 while(scanf("%d",&n)!=EOF) 7 { 8 for(i=0;i<1001;i++) 9 t[i]=0;10 char a[1001][16];11 if(n==0)12 return 0;13 for(i=0;i<n;i++)14 scanf("%s",&a... 阅读全文

posted @ 2012-08-02 16:41 mycapple 阅读(163) 评论(0) 推荐(0)

HDU 1002 A + B Problem II

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char op1[1002],op2[1002]; 6 int c,i,j,n,m,s1[1002],s2[1002],len1,len2,count; 7 count=1; 8 scanf("%d",&n); 9 m=n;10 while(m--)11 {12 memset(s1,0,1002*sizeof(int));13 memset(s2,0,1002*sizeof(int));... 阅读全文

posted @ 2012-08-02 16:40 mycapple 阅读(163) 评论(0) 推荐(0)

POJ 1928 The Peanuts

摘要: 1 #include <iostream> 2 #include <math.h> 3 #define N 100 4 using namespace std; 5 6 int field[N][N]; 7 8 int main() 9 {10 int m, n, k, t, i, j;11 scanf("%d", &t);12 while (t--)13 {14 scanf("%d%d%d", &m, &n, &k);15 for (i=1; i<=m; i++)16 for (j=1; j 阅读全文

posted @ 2012-08-02 16:37 mycapple 阅读(249) 评论(0) 推荐(0)

POJ 2080 Calendar

摘要: 1 #include<stdio.h> 2 int rm[]={31,29,31,30,31,30,31,31,30,31,30,31}; 3 int pm[]={31,28,31,30,31,30,31,31,30,31,30,31}; 4 int isp(int year) 5 { 6 if((year%4==0&&year%100!=0)||year%400==0) return 1; 7 8 return 0; 9 }10 int main()11 {12 13 int y,m,n,d,dd,day;14 while(... 阅读全文

posted @ 2012-08-02 16:37 mycapple 阅读(242) 评论(0) 推荐(0)

POJ 2210 Metric Time

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 5 int year,mon,day,hour,min,sec,myear,mmon,mday,mhour,mmin,msec; 6 int i,n; 7 scanf("%d",&n); 8 while(n--) 9 {10 scanf("%d%*c%d%*c%d%*c%d%*c%d%*c%d",&hour,&min,&sec,&am 阅读全文

posted @ 2012-08-02 16:36 mycapple 阅读(171) 评论(0) 推荐(0)

NYOJ263-精挑细选

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int i,j,m,t,N; 5 unsigned a[1010][3]; 6 scanf("%d",&N); 7 while(N--) 8 { 9 scanf("%d",&m);10 for(i=1;i<=m;i++)11 for(j=0;j<3;j++)12 scanf("%ld",&a[i][j]);13 for(i=1,a[0][0]=0;i<=m;i++)14 if(a[... 阅读全文

posted @ 2012-08-02 16:35 mycapple 阅读(286) 评论(0) 推荐(0)

NYOJ111-分数加减法

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 char operand; 6 int a,b,c,d,e,f,flag,end; 7 while(scanf("%d/%d%c%d/%d",&a,&b,&operand,&c,&d)!=EOF) 8 { 9 if(operand=='+') //e为分子,f为分母 10 e=a*d+b*c;11 else12 e=a*d-b*c;13 f=b*d;14 ... 阅读全文

posted @ 2012-08-02 16:33 mycapple 阅读(299) 评论(0) 推荐(0)

NYOJ94-cigarettes

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int n,k,N,s; 5 scanf("%d",&N); 6 while(N--) 7 { 8 scanf("%d%d",&n,&k); 9 for(s=n;n>=k;n=n/k+n%k)10 s+=n/k;11 printf("%d\n",s);12 }13 return 0;14 }15 阅读全文

posted @ 2012-08-02 16:32 mycapple 阅读(208) 评论(0) 推荐(0)

NYOJ97-兄弟郊游问题

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int N,M,x,y,z; 5 scanf("%d",&N); 6 while(N--) 7 { 8 scanf("%d%d%d%d",&M,&x,&y,&z); 9 printf("%.2f\n",z*((float)(M*x)/(y-x)));10 }11 return 0;12 } 阅读全文

posted @ 2012-08-02 16:32 mycapple 阅读(277) 评论(0) 推荐(0)

NYOJ71-独木舟上的旅行

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int cmp(const void *a,const void *b) 4 { 5 return *(int *)b-*(int *)a;//降序 6 } 7 int main() 8 { 9 int i,s,w,n,num,max,min;10 int a[400];11 scanf("%d",&s);12 while(s--)13 {14 num=0;15 scanf("%d%d",&w,&n);16 f... 阅读全文

posted @ 2012-08-02 16:31 mycapple 阅读(206) 评论(0) 推荐(0)

NYOJ72-Financial Management

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int i; 5 float a[13]; 6 for(i=1;i<13;i++) 7 scanf("%f",&a[i]); 8 for(i=1,a[0]=0;i<13;i++) 9 a[0]+=a[i];10 printf("%.2f\n",a[0]/12);11 return 0;12 } 阅读全文

posted @ 2012-08-02 16:31 mycapple 阅读(205) 评论(0) 推荐(0)

NYOJ69-数的长度 2

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int strrling(int n) 4 { 5 const double p=acos(-1.0); 6 double c1=log10(2*p); 7 double c2=0.434294481903; 8 double c3=log10(1.0*n); 9 int s=1;10 if(n>3)11 s=(int)((c3+c1)/2+n*(c3-c2)+1);12 return s;13 }14 int main()15 {16 i... 阅读全文

posted @ 2012-08-02 16:30 mycapple 阅读(154) 评论(0) 推荐(0)

NYOJ69-数的长度

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int i,j,k; 6 double sum; 7 int n,N; 8 scanf("%d",&n); 9 while(n--)10 {11 sum=0;12 scanf("%d",&N);//log10(N!)=log10(1)+log10(2)+log10(3)+.....+log10(N);13 for(j=1;j<=N;j++)14 sum+=log10... 阅读全文

posted @ 2012-08-02 16:29 mycapple 阅读(171) 评论(0) 推荐(0)

NYOJ60-谁获得了最高奖学金

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 typedef struct STU 6 { 7 char name[20]; 8 int score1,score2,num,sum; 9 char m,w;10 }stu;11 int i,k,total,n,N;12 stu s[100];13 scanf("%d",&N);14 while(N--)15 {16 scanf("%d",&n... 阅读全文

posted @ 2012-08-02 16:28 mycapple 阅读(440) 评论(0) 推荐(0)

NYOJ66-分数拆分

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int N; 6 scanf("%d",&N); 7 while(N--) 8 { 9 int k,x,y;10 scanf("%d",&k);11 for(y=k+1;y<=2*k;y++)12 {13 for(x=k+1;x<=k*y;x++)14 if((x*y)%(x+y)==0&&(x*y)/(x+y)==k)//(x*y)%(x+y)==0这个必须要... 阅读全文

posted @ 2012-08-02 16:28 mycapple 阅读(328) 评论(0) 推荐(0)

NYOJ50-爱摘苹果的小明

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int cmp(const void *a,const void *b) 4 { 5 return *(int *)a-*(int *)b;//升序 6 } 7 int main() 8 { 9 int N,i,m,count;10 int a[20];11 scanf("%d",&N);12 if(N<=0||N>=100)13 return 0;14 while(N--)15 {16 count=0;17 ... 阅读全文

posted @ 2012-08-02 16:26 mycapple 阅读(281) 评论(0) 推荐(0)

NYOJ57-6174问题

摘要: 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 int main() 6 { 7 int n,i,j,sum,s1,s2,s; 8 int a[4]; 9 cin>>n;10 while(n--)11 {12 cin>>s;13 sum=1;14 while(s!=6174)15 {16 for(i=0;i<4;i++)17 {18... 阅读全文

posted @ 2012-08-02 16:26 mycapple 阅读(458) 评论(0) 推荐(0)

NYOJ34-韩信点兵 2

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int a,b,c,t=10; 6 scanf("%d%d%d",&a,&b,&c); 7 while(1) 8 { 9 if((t%3==a)&&(t%5==b)&&(t%7==c))10 {11 printf("%d\n",t);12 break;13 }14 if(t>100)15 printf("No ans... 阅读全文

posted @ 2012-08-02 16:25 mycapple 阅读(244) 评论(0) 推荐(0)

NYOJ48-小明的调查作业

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n,i,j,t,count=0; 6 int a[1010]; 7 scanf("%d",&n); 8 for(i=0;i<n;i++) 9 scanf("%d",a+i);10 for(i=0;i<=n-1;i++)11 {12 for(j=i+1;j<=n-1;j++)13 if(a[i]>a[j])14 {t=a[i];a[i]=a[j];a[j]=t;}1... 阅读全文

posted @ 2012-08-02 16:25 mycapple 阅读(315) 评论(0) 推荐(0)

NYOJ34-韩信点兵 1

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int a,b,c,n; 6 scanf("%d%d%d",&a,&b,&c); 7 n=(a*70+b*21+c*15)%105; 8 if(n>=10&&n<=100) 9 printf("%d\n",n);10 else11 printf("No answer");12 //system("pause");13 re 阅读全文

posted @ 2012-08-02 16:24 mycapple 阅读(238) 评论(0) 推荐(0)

NYOJ23取石子(一)

摘要: 1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int T,m,n; 6 cin>>T; 7 while(T--) 8 { 9 cin>>n>>m;10 if(n%(m+1)) cout<<"Win"<<endl;11 else cout<<"Lose"<<endl;12 }13 return 0;14 } 阅读全文

posted @ 2012-08-02 16:23 mycapple 阅读(194) 评论(0) 推荐(0)

NYOJ28-大数阶乘

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #define N 40000 5 int s[N]; 6 int main() 7 { 8 int i,j,k,t,n; 9 while(scanf("%d",&n)!=EOF)10 {11 memset(s,0,sizeof(s));//每次使用前都要清零 12 s[0]=1; //相当于s数组存贮的大数00000113 for(i=2;i<=n;i++)//计算n! 14 {15 for(.. 阅读全文

posted @ 2012-08-02 16:23 mycapple 阅读(368) 评论(0) 推荐(0)

HDU 2099 整除的尾数

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n,m,i,flag; 6 while(scanf("%d%d",&n,&m)&&(n||m)) 7 { 8 flag=0; 9 for(i=0;i<100;i++)10 if((n*100+i)%m==0)11 {12 if(flag==0) flag=1;13 else putchar(' ');14 ... 阅读全文

posted @ 2012-08-02 16:21 mycapple 阅读(461) 评论(0) 推荐(0)

HDU 2031 进制转换

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int m,n,r,k,i,flag; 6 int a[1000]; 7 while(scanf("%d%d",&n,&m)!=EOF) 8 { 9 k=0;flag=0;10 if(n<0)11 {12 flag=1;13 n=-n;14 }15 r=n%m;16 while(n)17 ... 阅读全文

posted @ 2012-08-02 16:20 mycapple 阅读(776) 评论(0) 推荐(0)

HDU 2030 汉字统计

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 char str[1100]; 4 int calc(char str[]) 5 { 6 int i,sum=0; 7 for(i=0;str[i];i++) 8 if(str[i]&0x80) 9 {sum++;i++;}//这里i++是由于汉字占两个字节, 10 return sum;11 }12 int main()13 {14 int n;15 scanf("%d%*c",&n);16 while(n--)17 {18 ... 阅读全文

posted @ 2012-08-02 16:19 mycapple 阅读(205) 评论(0) 推荐(0)

HDU 2029 Palindromes _easy version

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int IsPalindromes(char str[]) 5 { 6 int i,len=strlen(str); 7 for(i=0;i<len/2;i++) 8 if(str[i]!=str[len-i-1]) return 0; 9 return 1;10 }11 int main()12 {13 int n;14 char str[1010];15 scanf("%d%*c",&n);16 阅读全文

posted @ 2012-08-02 16:19 mycapple 阅读(376) 评论(0) 推荐(0)

HDU 2028 Lowest Common Multiple Plus

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int gcd(int a,int b) 5 { 6 return b==0?a:gcd(b,a%b);//辗转取余法 7 } 8 int main() 9 {10 int n,a,b,i,k;11 while(scanf("%d",&n)!=EOF)12 {13 scanf("%d",&b);14 for(i=1;i<n;i++)15 {16 scanf("% 阅读全文

posted @ 2012-08-02 16:18 mycapple 阅读(136) 评论(0) 推荐(0)

HDU 2027 统计元音

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int main() 5 { 6 int i,t,n=1; 7 char str[100]; 8 char tabstr[]="aeiou"; 9 int tab[300];10 scanf("%d%*c",&t);11 while(t--)12 {13 gets(str);14 memset(tab,0,sizeof(tab));15 for(i=0;str[... 阅读全文

posted @ 2012-08-02 16:17 mycapple 阅读(222) 评论(0) 推荐(0)

HDU 2026 首字母变大写 2

摘要: 1 #include <stdio.h> 2 #include <string.h> 3 #include <ctype.h> 4 #define N 100 5 int main() 6 { 7 char str[N]; 8 int i; 9 while (gets(str))10 {11 str[strlen(str)] = '\0';12 for (i = 0; i < strlen(str); i++)13 {14 if (i == 0 || (str[i-1] == ' ' &&... 阅读全文

posted @ 2012-08-02 16:16 mycapple 阅读(253) 评论(0) 推荐(0)

HDU 2025 查找最大元素

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 char t[128]; 6 char max; 7 int i; 8 while(gets(t)) 9 {10 for(max=i=0;t[i]!='\0';i++)11 {12 if(t[i]>max)13 max=t[i];14 }15 for(i=0;t[i]!='\0';i++)16 {17 ... 阅读全文

posted @ 2012-08-02 16:15 mycapple 阅读(472) 评论(0) 推荐(0)

HDU 2026 首字母变大写 1

摘要: 1 #include<stdio.h> 2 char str[110]; 3 int main() 4 { 5 int i; 6 while(gets(str)) 7 { 8 for(i=0;str[i];i++) 9 {10 if(i==0||(str[i-1]==' '&&str[i]!=' '))11 putchar(str[i]&0xDF);//0x开头的数据是16进制的 &是与运算符 c&0xdf是把小写转化为大写 x20是把大写转化为小写 12 ... 阅读全文

posted @ 2012-08-02 16:15 mycapple 阅读(318) 评论(0) 推荐(0)

HDU 2022 海选女主角

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int m,n,max,i,j,k,x,y; 6 int b[100][100]; 7 while(scanf("%d%d",&m,&n)!=EOF) 8 { 9 max=0;10 for(i=1;i<=m;i++)11 {12 for(j=1;j<=n;j++)13 {14 scanf("%d",&b[i][j]);15 ... 阅读全文

posted @ 2012-08-02 16:14 mycapple 阅读(434) 评论(0) 推荐(0)

HDU 2024 C语言合法标识符

摘要: 1 #include <ctype.h> 2 #include <stdio.h> 3 int main() 4 { 5 int n, d, i; 6 char sym[64]; 7 scanf("%d%*c", &n); 8 while (n--) 9 {10 gets(sym);11 if (sym[0] != '_' && !isalpha(sym[0]))12 {13 puts("no");14 continue;15 }16 ... 阅读全文

posted @ 2012-08-02 16:14 mycapple 阅读(318) 评论(1) 推荐(0)

HDU 2019 数列有序

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int n,m,i,x[101]; 5 while(scanf("%d%d",&n,&m),n||m) 6 { 7 for(i=0;i<n;i++) 8 scanf("%d",x+i); 9 for(i=n;i&&x[i-1]>m;i--)10 x[i]=x[i-1];11 x[i]=m;12 for(i=0;i<=n-1;i++)13 printf("%d ",x[i]);14 ... 阅读全文

posted @ 2012-08-02 16:13 mycapple 阅读(868) 评论(0) 推荐(0)

HDU 2015 偶数求和

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int n,m,flag; 5 int i,sum,cnt; 6 while(scanf("%d%d",&n,&m)!=EOF) 7 { 8 flag=0; 9 sum=0;10 cnt=0;11 for(i=1;i<=n;i++)12 {13 sum+=i*2;14 cnt++;15 if(cnt==m)16 ... 阅读全文

posted @ 2012-08-02 16:12 mycapple 阅读(1083) 评论(0) 推荐(0)

HDU 2018 母牛的故事

摘要: 1 #include<stdio.h> 2 int cow(int n) 3 { 4 if(n<=4) 5 return n; 6 else 7 return cow(n-1)+cow(n-3); 8 } 9 int main()10 {11 int n,m;12 while(scanf("%d",&n)&&n)13 {14 m=cow(n);15 printf("%d\n",m);16 }17 return 0;18 } 阅读全文

posted @ 2012-08-02 16:12 mycapple 阅读(1408) 评论(0) 推荐(0)

HDU 2010 水仙花数 2

摘要: 1 #include<stdio.h> 2 int IsNarcissus(int n) 3 { 4 int i,j,k; 5 i=n/100; 6 j=n/10%10; 7 k=n%10; 8 if(n==i*i*i+j*j*j+k*k*k) return 1; 9 return 0;10 }11 int main(int m,int n)12 {13 while(~scanf("%d%d",&m,&n))14 {15 while(!IsNarcissus(m)&&m<=n) m++;16 if... 阅读全文

posted @ 2012-08-02 16:11 mycapple 阅读(237) 评论(0) 推荐(0)

OpenJudge 2973 Skew数

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int i,s,t,sum; 5 char skew[32]; 6 while(scanf("%s",skew)) 7 { 8 for(sum=t=i=0;skew[i];i++) 9 {10 sum=(sum<<1)+skew[i]-'0';11 t+=skew[i]-'0';12 }13 sum=(sum<<1)-t;14 if(!sum) break... 阅读全文

posted @ 2012-08-02 16:10 mycapple 阅读(284) 评论(0) 推荐(0)

OpenJudge 2972 确定进制

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 char p[32],q[32],r[32]; 4 int MinRadix()//找出最低限的进制 5 { 6 int i,minRadix; 7 minRadix=1; 8 for(i=0;p[i];i++)//找出p[i]最大的数 9 if(minRadix<p[i]-'0') minRadix=p[i]-'0';10 for(i=0;q[i];i++)11 if(minRadix<q[i]-'0') minRadix= 阅读全文

posted @ 2012-08-02 16:09 mycapple 阅读(445) 评论(0) 推荐(0)

OpenJudge 2742 约瑟夫问题 2

摘要: 1 #include <stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n, m, i,s; 6 while(scanf("%d%d",&n,&m)&&(n||m)) 7 { s=0; 8 for (i=2;i<=n;i++) s=(s+m)%i; 9 printf ("%d\n", s+1);10 }11 //system("pause");12 return 0;13 }2.问题描述:n个人(编号1~n),从1开 阅读全文

posted @ 2012-08-02 16:07 mycapple 阅读(403) 评论(0) 推荐(0)

OpenJudge 2746 约瑟夫问题 1

摘要: 1 #include<stdio.h> 2 typedef struct Node 3 { 4 int data; 5 Node *next; 6 Node(int i){ //Node函数 7 data=i; 8 next=NULL; 9 }10 }node;11 int main()12 {13 int i,m,n;14 node *head,*p,*q;15 while(scanf("%d%d",&n,&m),m||n)16 {17 if(m==1) ... 阅读全文

posted @ 2012-08-02 16:05 mycapple 阅读(427) 评论(0) 推荐(0)

HDU 2010 水仙花数 1

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int IsNarcissus(int n) 4 { 5 int i,j,k; 6 i=n/100; 7 j=n/10%10; 8 k=n%10; 9 if(n==i*i*i+j*j*j+k*k*k) 10 return 1;11 else return 0;12 }13 int main()14 {15 int i,m,n,flag;16 while(scanf("%d%d",&m,&n)!=EOF)17 {18 ... 阅读全文

posted @ 2012-08-02 15:46 mycapple 阅读(777) 评论(0) 推荐(0)

导航