2019 Multi-University Training Contest 7 HDU - 6651 Final Exam (构造)

Final Exam
Final Exam is coming! Cuber QQ has now one night to prepare for tomorrow’s exam.

The exam will be a exam of problems sharing altogether m points. Cuber QQ doesn’t know about the exact distribution. Of course, different problems might have different points; in some extreme cases, some problems might worth 0 points, or all m points. Points must be integers; a problem cannot have 0.5 point.

What he knows, is that, these n problems will be about n totally different topics. For example, one could be testing your understanding of Dynamic Programming, another might be about history of China in 19th century. So he has to divide your night to prepare each of these topics separately. Also, if one problem is worth x points in tomorrow’s exam, it takes at least x+1 hours to prepare everything you need for examination. If he spends less than x+1 hours preparing, he shall fail at this problem.

Cuber QQ’s goal, strangely, is not to take as much points as possible, but to solve at least k problems no matter how the examination paper looks like, to get away from his parents’ scoldings. So he wonders how many hours at least he needs to achieve this goal.
Input
The first line of the input is an integer t (1≤t≤20 000), denoting the number of test cases.

Each test case are three space-separated integers n,m,k (0≤m≤109, 1≤k≤n≤109).
Output
For each test case, output the number of hours Cuber QQ needs.
Sample Input
2
1 10 1
10 109 10
Sample Output
11
1100

Hint
Cuber QQ should solve one problem in sample 1, so he at least prepares 11 hours when the problem one is 10 point.
Cuber QQ should solve all the ten problems in sample 2, so he at least prepares 110 hours for each problem because there may be one problem is 109 point.

题意:
n道题目,总分是m分,每做对一道题目就要对应的付出一定的复习时间,每道题目可以是m分,也可以是0分,反正这n道题目的总分是等于m的,比如改题目是x分,那么就需要付出x+1分钟复习,要不然过不了;
然后老师就会想办法不让你过,问做对k道题目,最少需要多少时间呢??

分析:
老师想不让你过,那肯定是针对你花费时间最少的n-k+1道题目,这样的话你就才做对k-1道题目,因此,这n-k+1道题目你必须付出m+1分钟才可以;
到现在还不能保证你能够过,因为剩下的k-1道题目你要付出多少时间呢??
剩下的k-1道题目就是你n-k+1道题目里面分值最大的题目了。为啥?
老师不是想针对你n-k+1道题目嘛,那他肯定是针对你在这n-k+1道题目里面用时最少的,这样你就过不了了,因此你只需在剩下的k-1道题目中用n-k+1道题目中用时最多的就好了(有人可能会问,那不就是m分吗,但是这里的m分我们一开始就处理了,就是那个m+1呀,,,因此剩下最大的时间即使均分的值了)

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int N=1e5+10;
const int INF=0x3f3f3f3f;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif // ONLINE_JUDGE
    int T;
    scanf("%d",&T);
    while(T--){
        ll n,m,k;
        scanf("%lld%lld%lld",&n,&m,&k);
        ll ans=m+1;
        ans+=(ll)ceil(1.0*(m+1)/(n-k+1))*(k-1);
        printf("%lld\n",ans);
    }
    return 0;
}


发布了229 篇原创文章 · 获赞 17 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/c___c18/article/details/99409738