您当前的位置: 首页 >  算法

星许辰

暂无认证

  • 1浏览

    0关注

    466博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

杭电OJ第11页2060~2064算法题(C语言)

星许辰 发布时间:2021-01-15 18:43:12 ,浏览量:1

目录
  • 2060.Snooker
  • 2061.Treasure the new start, freshmen!
  • 2062.Subset sequence
  • 2063.过山车
  • 2064.汉诺塔III

2060.Snooker
Problem Description
background:
Philip likes to play the QQ game of Snooker when he wants a relax, though
 he was just a little vegetable-bird. Maybe you hadn't played that game 
 yet, no matter, I'll introduce the rule for you first.
There are 21 object balls on board, including 15 red balls and 6 color 
balls: yellow, green, brown, blue, pink, black.
The player should use a white main ball to make the object balls roll into 
the hole, the sum of the ball's fixed value he made in the hole is the 
player's score. The player should firstly made a red ball into the hole, 
after that he gains red-ball's value(1 points), then he gets the chance to 
make a color ball, then alternately. The color ball should be took out 
until all the red-ball are in the hole. In other word, if there are only 
color balls left on board, the player should hit the object balls in this
 order: yellow(2 point), green(3 point), brown(4 point), blue(5 point), 
 pink(6 point), black(7 point), after the ball being hit into the hole, 
 they are not get out of the hole, after no ball left on board, the game 
 ends, the player who has
the higher score wins the game. PS: red object balls never get out of the 
hole.
I just illustrate the rules that maybe used, if you want to contact more 
details, visit http://sports.tom.com/snooker/ after
the contest.

for example, if there are 12 red balls on board(if there are still red 
ball left on board, it can be sure that all the color
balls must be on board either). So suppose Philp can continuesly hit the 
ball into the hole, he can get the maximun score is
12 * 1 (12 red-ball in one shoot) + 7 * 12(after hit a red ball, a black 
ball which was the most valuable ball should be the target) + 2 + 3 + 4 + 
5 + 6 + 7(when no red ball left, make all the color ball in hole).
Now, your task is to judge whether Philip should make the decision to give
 up when telling you the condition on board(How many object balls still 
left not in the hole and the other player's score). If Philp still gets 
the chance to win, just print "Yes", otherwise print "No". (PS: if the max 
score he could get on board add his current score is equal to the 
opponent's current score, still output "Yes")
Input
The first line contains a numble N indicating the total conditions. Then 
followed by N lines, each line is made of three integers:
Ball_Left P_Score O_Score represeting the ball number left on board, 
Philp's current score, and the opponent's current score.
All the input value are in 32 bit integer value range.
Output
You should caculate the max score left Philp can gain, and judge whether 
he has the possiblity to win.
Sample Input
2
12 1 1
1 30 39
Sample Output
Yes
No

分析:通过分析题意可知,要根据球台上剩余的球数来计算Philp目前能够得到的最大分数: (1)Ball_Left>6,球台上还有红球,为了获得最多的分数,每一次打进红球后都选择打黑球; (2)Ball_Left6){ //球台上还有红球,为了获得最多的分数,每一次打进红球后都选择打黑球 sum=(Ball_Left-6)*8+2+3+4+5+6+7; }else{ //剩余的球均为彩色球 sum=0; for(i=0;i=O_Score){ printf("Yes\n"); }else{ printf("No\n"); } } } 2061.Treasure the new start, freshmen!

Problem Description
background:
A new semester comes , and the HDU also meets its 50th birthday. No matter 
what's your major, the only thing I want to tell you is:"Treasure the 
college life and seize the time." Most people thought that the college 
life should be colorful, less presure.But in actual, the college life is 
also busy and rough. If you want to master the knowledge learned from the 
book, a great deal of leisure time should be spend on individual study and 
practise, especially on the latter one. I think the every one of you 
should take the learning attitude just as you have in senior school.
"No pain, No Gain", HDU also has scholarship, who can win it? That's 
mainly rely on the GPA(grade-point average) of the student had got. Now, I 
gonna tell you the rule, and your task is to program to caculate the GPA.
If there are K(K > 0) courses, the i-th course has the credit Ci, your 
score Si, then the result GPA is
GPA = (C1 * S1 + C2 * S2 +……+Ci * Si……) / (C1 + C2 + ……+ Ci……) (1             
关注
打赏
1665627467
查看更多评论
0.0413s