题意:有n门课,价值之和为m,每门课的价值可能是0到m
一门价值为x的课需要花至少x+1时间准备才能通过
问不管价值如何分配都能通过至少k门课的最小总准备时间
m,n,k<=1e9
思路:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 typedef unsigned int uint; 5 typedef unsigned long long ull; 6 typedef pair<int,int> PII; 7 typedef pair<ll,ll> Pll; 8 typedef vector<int> VI; 9 typedef vector<PII> VII; 10 #define N 1100000 11 #define M 4100000 12 #define fi first 13 #define se second 14 #define MP make_pair 15 #define pi acos(-1) 16 #define mem(a,b) memset(a,b,sizeof(a)) 17 #define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++) 18 #define per(i,a,b) for(int i=(int)a;i>=(int)b;i--) 19 #define lowbit(x) x&(-x) 20 #define Rand (rand()*(1<<16)+rand()) 21 #define id(x) ((x)<=B?(x):m-n/(x)+1) 22 #define ls p<<1 23 #define rs p<<1|1 24 25 const ll MOD=1e9+7,inv2=(MOD+1)/2; 26 double eps=1e-6; 27 int INF=1e9; 28 29 30 ll read() 31 { 32 ll v=0,f=1; 33 char c=getchar(); 34 while(c<48||57<c) {if(c=='-') f=-1; c=getchar();} 35 while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar(); 36 return v*f; 37 } 38 39 40 41 int main() 42 { 43 //freopen("1.in","r",stdin); 44 int cas; 45 scanf("%d",&cas); 46 while(cas--) 47 { 48 ll n=read(),m=read()+1,k=read(); 49 ll t=n-k+1; 50 if(m%t) printf("%I64d\n",m+(k-1)*(m/t+1)); 51 else printf("%I64d\n",m+(k-1)*(m/t)); 52 } 53 54 return 0; 55 }