## C语言（挑战ACM-ICPC，DEVFORGE学编程社区）

1、Double

``` 1 #include <stdio.h>
2 int main()
3 {
4     int arr[20] = {0}, i, x, count=0;
5     for(i=0; ; ++i){
6         scanf("%d",&x);
7         if(x==0) break;
8         arr[i] = x;
9     }
10     for(int j=0; j<i; ++j){
11         if(arr[j]%2) continue;
12         for(int k=0; k<i; ++k){
13             if(arr[j]/2==arr[k])
14                 count++;
15         }
16     }
17     printf("%d",count);
18     return 0;
19 }```

2、Houseboat

``` 1 #include <stdio.h>
2 #include <math.h>
3
4 inline void one(int i){
5     double x,y;
6     scanf("%lf%lf",&x,&y);
7     double r = sqrt(x*x+y*y);
8     double area = 0.5*3.14159265*r*r;
9     int n =ceil(area/50);
10     printf("%d %d\n",i,n);
11 }
12 int main(){
13     int n ;
14     int i=1;
15     scanf("%d",&n);
16     while(n--){
17         one(i);
18         i++;
19     }
20     return 0;
21 }```

3、Sum of Consecutive

``` 1 #include <stdio.h>
2 #include <math.h>
3 #define N 1000
4 int isPrime(int n){
5     for(int i=2; i<n; ++i)
6         if(n%i==0)
7             return 0;
8     return 1;
9 }
10 int main()
11 {    /* 1 */
12     int arr[N] = {0}, index=0, sum = 0;
13     for(int j=2;sum<10000 ; ++j)
14         if(isPrime(j)){
15             sum += j;
16             arr[index++] = j;
17         }
18     /* 2 */
19     int n;
20     scanf("%d",&n);
21     while(n){
22         int count = 0;
23         for(int j=0;j<index ; ++j){
24             sum = 0;
25             for(int k=j;k<index ; ++k)
26             {
27                 sum += arr[k];
28                 if(sum==n){
29                     count++;
30                 }
31                 if(sum>n) break;
32             }
33         }
34         printf("%d\n",count);
35         scanf("%d",&n);
36     }
37     return 0;
38 }```

4、Specialized Number

``` 1 #include <stdio.h>
2 int fun(int n, int base)
3 {
4     int sum = 0;
5     while(n)
6     {
7         sum += n%base;
8         n /= base;
9     }
10     return sum;
11 }
12 int main()
13 {
14     for(int n = 2992; n<9999; ++n){
15         int sum = fun(n,10);
16         if(sum ==fun(n,12) && sum == fun(n,16))
17             printf("%d\n",n);
18     }
19     return 0;
20 } ```