摘要:
1 #include<stdio.h> 2 3 int main() 4 { 5 int i, ncases; 6 int n; 7 8 while(scanf("%d", &ncases) != EOF) 9 {10 while(ncases--)11 {12 scanf("%d", &n);13 i = 0;14 while( n != 0)15 {16 if(n%2 == 1)17 ... 阅读全文
摘要:
1 #include<stdio.h> 2 #include<math.h> 3 4 int sumdigit(int n) 5 { 6 int sum = 0; 7 while(n != 0) 8 { 9 sum += n%10;10 n /= 10;11 }12 return sum;13 }14 15 int Prime(int n) //判断素数因子的位数之和,这是关键。16 {17 int i, tn=n, sum =0;18 19 for( i = 2; i*i <= n; i... 阅读全文
摘要:
1 #include<stdio.h> 2 3 int gcd(int a,int b) 4 { 5 if(b == 0) 6 return a; 7 else 8 return gcd(b,a%b); 9 }10 11 int main()12 {13 int step, mod;14 15 while(scanf("%d%d", &step,&mod) != EOF)16 {17 printf("%10d%10d",step,mod);18 if(gcd(step,mod) == 1... 阅读全文
摘要:
1 #include<stdio.h> 2 3 int main() 4 { 5 int k, n; 6 long long num; 7 8 while(scanf("%d", &n) != EOF) 9 {10 k = 1; 11 num = 1;12 while(num%n != 0)13 {14 num = (num*10+1)%n; //一开始把n忘了写超时了,最后改了一下 15 k++;16 }17 prin... 阅读全文
摘要:
1 #include<stdio.h> 2 3 int main() 4 { 5 int ncases, k; 6 long n; 7 8 while(scanf("%d", &ncases) != EOF) 9 {10 while (ncases--)11 {12 scanf("%ld", &n);13 k = 1;14 while(n != 1)15 {16 k++;17 ... 阅读全文
摘要:
1 #include<stdio.h> 2 #include<stdlib.h> 3 #define N 10002 4 5 int cmp(const void *a,const void *b) 6 { 7 return *(int *)a - *(int *)b; 8 } 9 10 int main()11 {12 int i,a[N], b[N],j;13 int n, m, count;14 15 while(scanf("%d %d", &n, &m) != EOF)16 {17 for(i=0; i<n; i++) 阅读全文
摘要:
1 #include<stdio.h> 2 #include<stdlib.h> 3 #define MAX 100 4 5 typedef struct 6 { 7 int a; 8 int b; 9 }Point;10 Point P[MAX];11 12 int father[MAX],num[MAX];13 int Mak_set(int n)14 {15 int i;16 for (i=1; i<=n; i++)17 {18 father[i] = i; 19 num[i] = 0; 20 }21 }22 23 int Find_se... 阅读全文
摘要:
1 #include<stdio.h> 2 3 int main() 4 { 5 int i, k, h[25], max; 6 int j, temp, dp[25]; 7 8 while(scanf("%d", &k) != EOF) 9 {10 for(i=1; i<=k; i++)11 {12 scanf("%d", &h[i]);13 }14 15 for (i=k; i>0; i--)16 {17 temp = 0;... 阅读全文
摘要:
#include<stdio.h>int main(){ int i,j, N, h[1002],dp2[1002]; int temp, dp[1002], max; while(scanf("%d", &N) != EOF) { for(i=1; i<=N; i++) { scanf("%d", &h[i]); } dp[1] = 1; for (i=2; i<=N; i++) { temp = 0; for (j=1; j<i; j++) { if ((h[i]>h[j]) && 阅读全文
摘要:
#include<stdio.h>int main(){ int i, j, N, temp, max; int high[102],dp1[102],dp2[102]; while(scanf("%d", &N) != EOF) { scanf("%d", &high[1]); for(i=2; i<=N; i++) { scanf(" %d",&high[i]); } dp1[1] = 1; for (i=2; i<=N; i++) { temp = 0; for (j=1; j&l 阅读全文