[HDOJ6651] Final Exam (greedy)

Meaning of the questions: There are n course, value for the sum of m, the value of each course may be 0 to m

A value for x of course it takes time to prepare at least x + 1 to pass

Q. No matter how value can be assigned a minimum total preparation time by at least k the course

m,n,k<=1e9

Ideas:

 

 

 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 }

 

Guess you like

Origin www.cnblogs.com/myx12345/p/11653998.html