hdu2035:

计算 A的B次方的后三位,只要累乘的时候不断对1000取模,水题

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int A,B,i;
 5     while(scanf("%d%d",&A,&B)!=EOF)
 6     {
 7         if (A!=0||B!=0)
 8         {
 9             if (A>999) A-=(A/1000)*1000;
10             int C=A;
11             for (i=1;i<=B-1;i++)
12             {
13                 C*=A;
14                 if (C>999) C-=(C/1000)*1000;
15             }
16             printf("%d\n",C);
17         }
18     }
19     return 0;
20 }
View Code

 

hdu2036:

给出点,计算多边形面积,昂,当时这道题WA了好多次,最后算面积是分成三角形用矩阵行列式算的并且还会有凹多边形

 1 #include<stdio.h>
 2 #include<math.h>
 3 double s(int x1,int y1,int x2,int y2,int x3,int y3);
 4 
 5 int main()
 6 {
 7     int n,i,j;
 8     while(scanf("%d",&n)!=EOF)
 9     {
10         if (n!=0)
11         {
12             int x[100],y[100];
13             double S=0;
14             for (i=0;i<n;i++) scanf("%d%d",&x[i],&y[i]);
15             for (j=1;j<=n-2;j++) S+=s(x[0],y[0],x[j],y[j],x[j+1],y[j+1]);
16             printf("%.1f\n",S);
17         }
18     }
19     return 0;
20 }
21 
22 double s(int x1,int y1,int x2,int y2,int x3,int y3)
23 {
24     double s1;
25     s1=(x1*y2+x3*y1+x2*y3-x3*y2-x2*y1-x1*y3)/2.0;
26     return s1;
27 }
View Code

 

hdu2037:

给出很多个节目的开始和结束时间,问最多能看多少节目;

把结束时间排个序,然后贪心依次选择结束时间最早并且开始时间在上一个选择的节目结束时间之后的就行,想那个时候我竟然还不会用结构体,排序只会冒泡……

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n;
 5     while (scanf("%d",&n)!=EOF)
 6     {
 7         if (n!=0){
 8         int a[100],b[100],i,j,t,count,x;
 9         for (i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);
10         for (i=0;i<n;i++)
11         {
12             for (j=i+1;j<n;j++)
13             {
14                 if (b[i]>b[j])
15                 {
16                     t=a[i];
17                     a[i]=a[j];
18                     a[j]=t;
19                     t=b[i];
20                     b[i]=b[j];
21                     b[j]=t;
22                 }
23             }
24         }
25         count=1;
26         x=b[0];
27         for (i=1;i<n;i++)
28         {
29             if (a[i]>=x)
30             {
31                 x=b[i];
32                 count++;
33             }
34         }
35         printf("%d\n",count);
36     }
37     }
38     return 0;
39 }
View Code

 

hdu2039:

给出三边长度判断是否组成三角形,水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int M;
 5     while (scanf("%d",&M)!=EOF)
 6     {
 7         int i;
 8         for (i=0;i<M;i++) 
 9         {
10             double A,B,C;
11             scanf("%lf%lf%lf",&A,&B,&C);
12             if ((A+B>C)&&(A+C>B)&&(B+C>A)) printf("YES\n");
13             else printf("NO\n");
14         }
15     }
16     return 0;
17 }
View Code

 

hdu2040:

判断两数是否是亲和数,暴力水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int M;
 5     while (scanf("%d",&M)!=EOF)
 6     {
 7         int i;
 8         for (i=0;i<M;i++) 
 9         {
10             long long A,B,j,sum=0;
11             bool flag=1;
12             scanf("%I64d%I64d",&A,&B);
13             for (j=1;j<=A/2;j++) if (A%j==0) sum+=j;
14             if (sum==B)
15             {
16                 sum=0;
17                 for (j=1;j<=B/2;j++) if (B%j==0) sum+=j;
18                 if (sum!=A) flag=0;
19             }
20             else flag=0;
21             if (flag) printf("YES\n");
22             else printf("NO\n");
23         }
24     }
25     return 0;
26 }
View Code