04.06 UCF Local Programming Contest 2017
A.Electric Bill
题意:简单计算题,超过1000部分额外算
1 #include<stdio.h> 2 int main(){ 3 int money1,money2; 4 long long int sum=0,n,num; 5 scanf("%d %d",&money1,&money2); 6 scanf("%lld",&n); 7 while(n--){ 8 sum=0; 9 scanf("%lld",&num); 10 if(num>1000){ 11 sum+=(num-1000)*money2; 12 sum+=1000*money1; 13 printf("%lld %lld\n",num,sum); 14 }else{ 15 printf("%lld %lld\n",num,num*money1); 16 } 17 } 18 }
B.Simplified Keyboard
题目:判断是题目中说的哪一类
1 #include<bits/stdc++.h> 2 using namespace std; 3 int pos[9] = {-10,-9,-8,-1,0,1,8,9,10}; 4 char a[27] = "abcdefghijklmnopqrstuvwxyz"; 5 int main() 6 { 7 int n; 8 scanf("%d",&n); 9 while(n--) 10 { 11 int i,j,k; 12 int flag = 3; 13 char s1[21],s2[21]; 14 scanf("%s %s",s1,s2); 15 if(strcmp(s1,s2)==0) 16 flag=1; 17 else 18 { 19 if(strlen(s1)!=strlen(s2)) 20 flag = 3; 21 else 22 { 23 24 flag = 2; 25 for(i = 0; i < strlen(s1); i++) 26 { 27 int isok = 0; 28 for(j = 0; j < 9; j++) 29 { 30 if(s2[i]-'a'+pos[j]>=0&&s2[i]-'a'+pos[j]<=25) 31 { 32 if(s1[i]==a[s2[i]-'a'+pos[j]]) 33 { 34 isok = 1; 35 break; 36 } 37 38 39 } 40 41 }if(isok == 1) 42 continue; 43 else {flag = 3;break;} 44 45 } 46 47 } 48 } 49 printf("%d\n",flag); 50 } 51 52 53 54 }
C.Singin' in the Rain
题目:和上场比赛的CDs题有点相同,只是贪心找最小即可,把样例一列出来,找找规律即可
1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 #include<iostream> 5 using namespace std; 6 int main(){ 7 int m,n,t,s; 8 long long int sum=0; 9 int a[1010]; 10 scanf("%d",&n); 11 while(n--){ 12 sum=0; 13 scanf("%d %d",&t,&s); 14 for(int i=0;i<s;i++){ 15 scanf("%d",&a[i]); 16 } 17 for(int i=0;i<s-1;i++){ 18 if(a[i]>a[i+1]){ 19 sum+=min((a[i]-a[i+1]+1),(a[i+1]+t-1-a[i])); 20 }else if(a[i]==a[i+1]){ 21 sum++; 22 }else if(a[i]+1==a[i+1]){ 23 continue; 24 }else{ 25 sum+=min((a[i+1]-a[i]-1),(a[i]+t-a[i+1]+1)); 26 } 27 } 28 printf("%lld\n",sum); 29 } 30 }
E.Simple Darts
题目:进行区域判断,通过反三角函数和圆位置进行相对判断,从而确定分数
1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cmath> 5 #include<string> 6 #include<map> 7 #include<sstream> 8 #include<cstring> 9 #include<vector> 10 #include<queue> 11 #define LL long long 12 const double pi=3.1415926; 13 using namespace std; 14 int main(){ 15 int n; 16 scanf("%d",&n); 17 while(n--){ 18 int w,b,d,s; 19 cin >> w >> b >> d >> s; 20 int t; 21 cin >> t; 22 long long int ans = 0; 23 while(t--){ 24 double x,y; 25 cin >> x >> y; 26 double r,jiao; 27 r = x*x + y*y; 28 double fen = 2*pi/w; 29 if(r < b*b){ 30 ans+=50; 31 }else if(r > b*b && r < d*d){ 32 if((y/x)>0&&y>0){ 33 jiao=atan(y/x); 34 }else if((y/x)>0&&y<0){ 35 jiao=atan(y/x)+pi; 36 }else if((y/x)<0&&y<0){ 37 jiao=atan(y/x)+2*pi; 38 }else if((y/x)<0&&x<0){ 39 jiao=atan(y/x)+pi; 40 }else if(x==0&&y>0){ 41 jiao=pi/2; 42 }else if(x==0&&y<0){ 43 jiao=(pi*3)/2; 44 }else if(y==0&&x<0){ 45 jiao=pi; 46 }else if(y==0&&x>0){ 47 jiao=0; 48 } 49 int j=jiao/fen; 50 ans+=((j+1)*2); 51 }else if(r > d*d && r < s*s){ 52 if((y/x)>0&&y>0){ 53 jiao=atan(y/x); 54 }else if((y/x)>0&&y<0){ 55 jiao=atan(y/x)+pi; 56 }else if((y/x)<0&&y<0){ 57 jiao=atan(y/x)+2*pi; 58 }else if((y/x)<0&&x<0){ 59 jiao=atan(y/x)+pi; 60 }else if(x==0&&y>0){ 61 jiao=pi/2; 62 }else if(x==0&&y<0){ 63 jiao=(pi*3)/2; 64 }else if(y==0&&x<0){ 65 jiao=pi; 66 }else if(y==0&&x>0){ 67 jiao=0; 68 } 69 int j=jiao/fen; 70 ans+=(j+1); 71 }else{ 72 ans += 0; 73 } 74 } 75 printf("%lld\n",ans); 76 } 77 }