2012湖南大学第八届程序设计竞赛 Incredible[公式]

题目地址:http://acm.hnu.cn/online/?action=problem&type=show&id=12312&courseid=215 

Incredible
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB
Total submit users: 9, Accepted users: 8
Problem 12312 : No special judgement
Problem description
2012湖南大学第八届程序设计竞赛 Incredible[公式]_第1张图片 Zhuge Liang, a person?of?great?wisdom?and?resourcefulness, who is capable of knowing things 500 years ago and predicting things 500 years later. What's incredible! He must could make large amounts of money if he still alive today because he could forecast everything. Now, we want invite him to help us to forecast the result of football matches. The Olympic Games of this year will hold in London, England. Assume that the rule of football in Olympic Games is as same as group stage. That's to say, there are n teams in a group and k teams which have higher scores will be promoted. Each team will play a match against each other teams of that group. For a match, the winner team will get A scores and the loser will get zero scores. Both two teams will get A/2(real number) scores if the result is tie. At last, each team will have a score and we will choose the k-highest teams as promoted teams. Now, can you calculate the least score that can ensure one team for promotion?

Input
There are several test cases end with EOF. For each test case, the first line is three integers n ( 0 < n ≤ 50 ), k ( 0 < k ≤ n ) and A ( 0 < A < 10000 ), which are described as above.


Output
For each the case, just output a real number rounded to two decimal places which means the least score that one team can be promoted.


Sample Input
4 2 3
3 1 2
Sample Output
7.50
4.00
Problem Source
The 2012 8th Hunan University Programming Contest

Submit   Discuss   Judge Status  Problems  Ranklist 

 

 

解体报告:

         题目大意:  

               给出N个球队,球队之间两两会进行一场比赛,赢的球队得A分,输的球队不得分,两个球队打平的话各得A/2分。现在在最开始一场球赛都没有打过的前提下,问球队需要至少多少分使得在任意情况下该球队都能排在前K名之内。

        

2012湖南大学第八届程序设计竞赛 Incredible[公式]_第2张图片

2012湖南大学第八届程序设计竞赛 Incredible[公式]_第3张图片

2012湖南大学第八届程序设计竞赛 Incredible[公式]_第4张图片

code:

 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int n,k;
 6     double A;
 7     double score;
 8     while(~scanf("%d%d%lf",&n,&k,&A))
 9     {
10         if(k==n)
11             score=0;
12         else
13         {
14             score=(n-1)*A;
15             while(--k)
16                 score-=(A/2.0);
17         }        
18         printf("%.2f\n",score);
19     }
20     return 0; 
21 }

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(程序设计)