题意:有n门课,价值之和为m,每门课的价值可能是0到m

一门价值为x的课需要花至少x+1时间准备才能通过

问不管价值如何分配都能通过至少k门课的最小总准备时间

m,n,k<=1e9

思路:

【HDOJ6651】Final Exam(贪心)-LMLPHP

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
#define N 1100000
#define M 4100000
#define fi first
#define se second
#define MP make_pair
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1 const ll MOD=1e9+,inv2=(MOD+)/;
double eps=1e-;
int INF=1e9; ll read()
{
ll v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} int main()
{
//freopen("1.in","r",stdin);
int cas;
scanf("%d",&cas);
while(cas--)
{
ll n=read(),m=read()+,k=read();
ll t=n-k+;
if(m%t) printf("%I64d\n",m+(k-)*(m/t+));
else printf("%I64d\n",m+(k-)*(m/t));
} return ;
}
05-17 12:04