首页 > 代码库 > hdu2060-2062

hdu2060-2062

hdu 2060 

斯诺克,读懂题意直接模拟

技术分享
 1 #include<stdio.h>
 2 
 3 int main(){
 4     int N;
 5     int i,a[21];
 6     a[0]=0;
 7     for(i=1;i<=6;i++){
 8         a[i]=(15-i)*i/2;
 9     }
10     for(i=7;i<=21;i++){
11         a[i]=a[i-1]+8;
12     }
13     while(scanf("%d",&N)!=EOF){
14         for(i=1;i<=N;i++){
15             int L,SP,SO;
16             scanf("%d%d%d",&L,&SP,&SO);
17             if(a[L]>=SO-SP) printf("Yes\n");
18             else printf("No\n");
19         }
20     }
21     return 0;
22 }
View Code

 

hdu 2061

求GPA并判断有没有挂科,直接模拟

技术分享
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main(){
 4     int N;
 5     while(scanf("%d",&N)!=EOF){
 6         for(int i=1;i<=N;i++){
 7             int K,j;
 8             scanf("%d",&K);
 9             double C[100],S[100];
10             char q[100];
11             bool f=0;
12             for(j=1;j<=K;j++){
13                 scanf("%s%lf%lf",q,&C[j],&S[j]);
14                 if(!f&&S[j]<60&&S[j]>=0)f=1;
15             }
16             if(f)printf("Sorry!\n");
17             else{
18                 double GKP=0,s=0;
19                 for (j=1;j<=K;j++){
20                     GKP+=S[j]*C[j];
21                     s+=C[j];
22                 }
23                 GKP=GKP*1.0/s;
24                 printf("%.2lf\n",GKP);
25             }
26             if(i!=N){
27                 printf("\n");
28             }
29         }
30     }
31     return 0;
32 }
View Code

 

hdu2062

技术分享
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     long long a[21],i;
 6     a[1]=1;
 7     for(i=2;i<=20;i++) a[i]=(i-1)*a[i-1]+1;
 8     long long n,m;
 9     while(scanf("%I64d%I64d",&n,&m)!=EOF){
10         long long b[21],k=m,l=n,t,s;
11         memset(b,0,sizeof(b));
12         for(;k>0;){
13             t=(k-1)/a[l]+1;
14             s=0;
15             for (t;t>0;t--){
16                 s++;
17                 while (b[s]) s++;
18             }
19             b[s]=1;
20             printf("%I64d",s);
21             k=(k-1)%a[l];
22             if (k==0) printf("\n");
23             else printf(" ");
24             l--;
25         }
26     }
27     return 0;
28 }
View Code

 

hdu2060-2062