标签:close gif color hal iostream ranking space win als
链接:https://www.jisuanke.com/contest/7330?view=challenges
A Find the Twins
题意:给一串数字看这对兄弟是否在其中。
需注意行末空格换行的格式问题
代码如下:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define pi acos(-1) 7 8 int a[15]; 9 10 int main(){ 11 int n; 12 scanf("%d", &n); 13 while(n --){ 14 bool flag1 = false, flag2 = false; 15 for(int i = 0; i < 10; i ++ ){ 16 scanf("%d", &a[i]); 17 if(a[i] == 18) 18 flag1 = true; 19 else if(a[i] == 17) 20 flag2 = true; 21 if(i != 9) printf("%d ", a[i]); 22 else printf("%d\n", a[i]); 23 } 24 if(flag1 && flag2) printf("both\n"); 25 else if(flag1 && !flag2) printf("mack\n"); 26 else if(!flag1 && flag2) printf("zack\n"); 27 else printf("none\n"); 28 if(n != 0) printf("\n"); 29 } 30 return 0; 31 }
B Medal Ranking
题意:给出奖牌数,问哪一种计算奖牌排名的方法可以使USA赢
代码如下:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define pi acos(-1) 7 8 int a[10]; 9 10 int main(){ 11 int n; 12 scanf("%d", &n); 13 while(n --){ 14 bool flag1 = false, flag2 = false; 15 int suma = 0, sumr = 0; 16 for(int i = 0; i < 6; i ++ ){ 17 scanf("%d", &a[i]); 18 if(i != 5) printf("%d ", a[i]); 19 else printf("%d\n", a[i]); 20 if(i < 3) 21 suma += a[i]; 22 else 23 sumr += a[i]; 24 } 25 if(suma > sumr) flag1 = true; 26 if(a[0] > a[3]) flag2 = true; 27 else if(a[0] == a[3] && a[1] > a[4]) flag2 = true; 28 else if(a[0] == a[3] && a[1] == a[4] && a[2] > a[5]) flag2 = true; 29 30 if(flag1 && flag2) printf("both\n"); 31 else if(flag1 && !flag2) printf("count\n"); 32 else if(!flag1 && flag2) printf("color\n"); 33 else printf("none\n"); 34 if(n != 0) printf("\n"); 35 } 36 return 0; 37 }
C Brownies vs. Candies vs. Cookies
(题目好长
题意:老师可以不断将点心一分为二,需要保证在每队过来拿点心之后还有剩下的点心,不然队员就不训练了(
代码如下:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define pi acos(-1) 7 8 int a[10]; 9 10 int main(){ 11 int n; 12 scanf("%d", &n); 13 int flag = 0; 14 char s[10]; 15 int sums, sumb, sumg, group; 16 while(n -- ){ 17 flag ++ ; 18 scanf("%d %d", &sums, &sumb); 19 scanf("%d", &sumg); 20 printf("Practice #%d: %d %d\n", flag, sums, sumb); 21 while(sumg -- ){ 22 scanf("%d", &group); 23 while(group >= sumb) 24 sumb *= 2; 25 printf("%d %d\n", group, sumb - group); 26 sumb -= group; 27 } 28 printf("\n"); 29 } 30 return 0; 31 }
D Lemonade Stand
题意:经营一个柠檬水摊点,提前知道以后每天会卖多少杯水、每天的柠檬价格和方糖的价格。求最少成本。
思路:记录每一天目前出现的最低价格,然后该天需要使用的柠檬和方糖在最低价格那天买即可。
代码如下:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define pi 3.14159265358979 7 8 int main(){ 9 int n; 10 scanf("%d", &n); 11 while(n --){ 12 int nn, lemon, sugar; 13 int sum = 0; 14 int minl = 0x3f3f3f3f, mins = 0x3f3f3f3f; 15 double left = 0; 16 int num = 0; 17 scanf("%d %d %d", &nn, &lemon, &sugar); 18 for(int i = 0; i < nn; i ++ ){ 19 int x, y; 20 int a, b, c; 21 int cnt = 0; 22 scanf("%d %d %d", &a, &b, &c); 23 minl = min(minl, b); 24 mins = min(mins, c); 25 x = a * lemon; 26 // while(num < a * sugar){ 27 // num += 80; 28 // cnt++; 29 // } 30 // num = num - a * sugar; 31 double aa = (double)a * (double)sugar / 16.0 / 5.0 - left; 32 y = ceil(aa); 33 left = double(y) - aa; 34 sum += x * minl; 35 sum += y * mins; 36 //sum += cnt * mins; 37 } 38 printf("%d\n", sum); 39 } 40 return 0; 41 }
E Rain Gauge
一个简单的数学题~
代码如下:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define pi 3.14159265358979 7 8 int main(){ 9 int n; 10 scanf("%d", &n); 11 while(n --){ 12 double d, r; 13 scanf("%lf %lf", &d, &r); 14 if(r >= d / sqrt(2)){ 15 printf("%.2lf\n", d * d); 16 } 17 else if(r <= d / 2){ 18 printf("%.2lf\n", pi * r * r); 19 } 20 else { 21 double x = acos(d / (2 * r));; 22 double cnt1 = (2 * pi - 8 * x) / 2 / pi; 23 double ans1 = cnt1 * pi * r * r; 24 double cnt2 = sqrt(r * r - (d/2) * (d/2)); 25 double ans2 = cnt2 * d / 2 * 4; 26 printf("%.2lf\n", ans1 + ans2); 27 } 28 } 29 return 0; 30 }
UCF Local Programming Contest 2015
标签:close gif color hal iostream ranking space win als
原文地址:https://www.cnblogs.com/moomight/p/12416970.html