1 solutions
-
0
C++ :
#include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #include<vector> #include<queue> #include<map> using namespace std; //const long long N=; long long G,g,t,c,gg,jk,gr,sy,sj,gs1,gs2,ling=0; int main() { cin>>G; while (G--) { cin>>g>>t>>c; jk=0;//閲戠熆 gr=1;//宸ヤ汉 for (int i=1;i<=t;i++) { sj=t-i+1;//鍓╀綑鏃堕棿 if (sj>c) { gs1=max(ling,g-sj*gr)/sj;//鐢卞墿浣欓噾鐭垮喅瀹氱殑宸ヤ汉鏁伴噺 gs2=jk/c;//鐢遍挶鍐冲畾鐨勫伐浜烘暟閲? gr+=min(gs1,gs2); jk-=c*min(gs1,gs2); if (jk>=c) { sy=min(g-sj*gr,sj); if (sy>c) gr++,jk-=c; } } if (g>=gr) g-=gr,jk+=gr; else jk+=g,g=0; } cout<<jk<<endl; } return 0; }
- 1
Information
- ID
- 888
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By