
# A题
题干
The jersey number 17 has been worn by several famous athletes, e.g., John Havlicek (NBA), Don Meredith (NFL), and Felipe Alou (MLB). The jersey number 18 has also been worn by several famous athletes, e.g., Peyton Manning (NFL), Joe Morgan (MLB), and Phil Jackson (NBA). These two jersey numbers are special to Dr. Orooji as well but for other reasons! So, whenever Dr. O is watching sports, he looks for these two special numbers.
Given a list of 10 numbers, determine which special jersey number is in the list.
输入描述
There is one input line, it consists of exactly 10single-space-separated distinct integers (each integer between 11and 99 inclusive) giving the jersey numbers for the players.
输出描述
Print one of four messages (17, 18, both, none), indicating which special jersey number is in the list.
输入1
11 99 88 17 19 20 12 13 33 44
输出1
17
输入2
11 12 13 14 15 16 66 88 19 20
输出2
none
输入3
20 18 55 66 77 88 17 33 44 11
输出3
both
输入4
12 23 34 45 56 67 78 89 91 18
输出4
18
解析:给10个数 17、18皆有输出both 有17无18输出17 有18无17输出18 17、18皆无输出none
代码
#include
using namespace std;
int main(){
int a[10],sum=0;
for(int i=0;i<10;i++)
cin>>a[i];
int flag1=0,flag2=0;
for(int j=0;j<10;j++){
if(a[j]==17)
flag1=1;
if(a[j]==18)
flag2=1;
}
if(flag1&&flag2)
cout<<"both";
else
if(flag1==1)
cout<<"17";
else if(flag2==1)
cout<<"18";
else
cout<<"none";
return 0;
}
# B题
题干
When different countries compete against each other (e.g., in the Olympics), they receive gold/silver/bronze medals. The countries can then be ranked in one of two ways: by “count” which is based on the total number of medals (regardless of the medal colors) or by “color” which is based on the number of gold medals (and silver medals if tied in gold medals, and bronze medals if tied in gold and silver).
Given the gold/silver/bronze medal counts for USA and Russia, you are to determine if USA wins in these two ranking methods.
输入描述
There is one input line, it consists of 6 integers (each integer between 0 and 500 inclusive); the first three integers represent (respectively) the gold, silver, and bronze medal counts for USA; the last three integers provide this info for Russia (in same order).
输出描述
Print one of four messages (count, color, both, none), indicating how USA can win. USA will win by count if its total medal count is higher than the total for Russia. USA will win bycolorif it has more gold medals than Russia (if tied in gold, then USA must have more silver; if tied in gold and silver, then USA must have more bronze).
题解:输入六个数 前三个是美国的金银铜牌 后三个是俄罗斯的金银铜牌 目的是问是按奖牌榜排美国能赢 还是按金牌榜排美国能赢 都能赢或者都不能赢 这跟A题差不多 直接水过去
代码
#include
using namespace std;
int main(){
int a1,a2,a3,b1,b2,b3;
int flag1=0,flag2=0;
cin>>a1>>a2>>a3>>b1>>b2>>b3;
//number
if(a1+a2+a3>b1+b2+b3){
flag1=1;
}
//gold
if(a1>b1) flag2=1;
if(a1==b1&&a2>b2) flag2=1;
if(a1==b1&&a2==b2&&a3>b3) flag2=1;
if(flag1==1&&flag2==1) cout<<"both";
else if(flag1==1&&flag2==0) cout<<"count";
else if(flag1==0&&flag2==1) cout<<"color";
else cout<<"none";
return 0;
}
# C题
题干
Everyone is welcome to the UCF Programming Team practices, and many students take advantage of this opportunity. The main benefit is that these students improve their problem solving and programming skills. Another benefit is that the students enjoy the refreshments Dr. Orooji brings every week! Dr. O usually brings candies but sometimes he brings cookies or brownies. Brownies are very popular and don’t usually last long, so Dr. O has to come up with some clever trick to make the brownies last longer (so that the students stay for the entire practice!). Well, the easiest solution is to cut the brownies in half; that will double the number of brownies.
If a group of students is approaching the refreshment table and Dr. O notices that the number of remaining brownies is less than or equal to the number of students in the group, Dr. O cuts the brownies in half to be sure they won’t be all gone after each student in the group grabs one brownie. Note that, if needed, Dr. O will cut the brownies more than once (as many times as needed). For example, if there are 3 brownies left and 24 students are approaching the table, Dr. O has to cut the brownies four times (3 → 6 → 12 → 24 → 48) to be sure the brownies won’t be all gone after each student in the group grabs one.
看起来有些长 不过仔细读不难理解
输入描述
The input provides the information about a practice. The first input line for the practice contains two integers (separated by a space): the number of students (between 1 and 30 inclusive) in the practice and the number of brownies (between 60 and 600 inclusive) Dr. O has brought that day. The next input line for the practice contains a positive integer, m, indicating how many groups of students approach the refreshment table to take brownies. This is followed by the number of students in each group, one number per line. Assume that the input values are valid, e.g., the number of students in a group will be at least 1 and it will not be greater than the number of students in the practice.
If a group of students is approaching the refreshment table and Dr. O notices that the number of remaining brownies is less than or equal to the number of students in the group, Dr. O cuts the brownies in half to be sure they won’t be all gone after each student in the group grabs one brownie. Note that, if needed, Dr. O will cut the brownies more than once (as many times as needed). For example, if there are 3 brownies left and 24 students are approaching the table, Dr. O has to cut the brownies four times (3 →6→12→24→48)to be sure the brownies won’t be all gone after each student in the group grabs one.
输出描述
Print one output line for each group of students approaching the refreshment table. Each output line should provide the number of students in a group approaching the table and the number of brownies left after each of these students has grabbed one brownie (note that cutting in halves may occur before grabbing).
样例输入1
20 60
8
15
10
20
18
9
12
2
10
样例输出1
15 45
10 35
20 15
18 12
9 3
12 12
2 10
10 10
样例输入2
15 100
4
1
2
3
5
样例输出2
1 99
2 97
3 94
5 89
又一道水题 只是题目稍长一些
#include
using namespace std;
int main(){
int a,b,c,n;
cin>>a>>b>>n;
while(n--){
cin>>c;
if(b>c){
b-=c;
}
else{
while(b<=c) b=b*2;
b-=c;
}
cout<
未经授权切勿转载
最后祝我们队明天正式赛加油
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)