QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614162#9408. Hero of the KingdomjackWA 1056ms3688kbC++14851b2024-10-05 15:45:422024-10-05 15:45:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 15:45:43]
  • 评测
  • 测评结果:WA
  • 用时:1056ms
  • 内存:3688kb
  • [2024-10-05 15:45:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p,a,b;
ll q,c,d;
ll m,t;

bool check(ll mid)
{
    ll g=t-(a+c)*mid;
    if(g<=0) return false;
    if(b+d==0)
    {
        if(g>0) return true;
    }
    ll s=g/(b+d);
    ll sum=m;
    while(s)
    {
        ll f=sum/p;
        if(f>=mid) return true;
        sum=sum+(sum/p*(q-p));
        s--;
    }
    if(sum/p>=mid) return true;
    return false;
}

void solve()
{
   cin>>p>>a>>b;
   cin>>q>>c>>d;
   cin>>m>>t;
   ll l=0,r=1e9;
   while(l<r)
   {
       ll mid=l+r+1>>1;
       if(check(mid)) l=mid;
       else r=mid-1;
   }
   if(m<p)
   {
      cout<<m<<'\n';
      return;
   }
   //cout<<check(6)<<endl;
   cout<<m+(q-p)*l<<'\n';
}

int main()
{
    int t;
    cin>>t;
    while(t--) solve();
    return 0;   
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3632kb

input:

3
5 2 3
8 1 5
14 36
5 2 0
8 1 3
17 6
100 1 0
10000 1 0
99 100000

output:

32
20
99

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1056ms
memory: 3688kb

input:

500
252 34074578 3386884
628907 1207868 18
279 125908043
17268783 50414369 277106
17532337 45 0
17268784 4606
5506 3465964 19
5543 4786900 7
8109756 50825
23718927 66546966 0
23718931 96 0
117090491 99433206
537909 33389755 4
537910 1362118 0
538731 3
47 117 17333
1724743 7699 402536
79710763 684241...

output:

1886244
17268784
8109756
117090495
538731
229759315
586
25929035
17864
7905961573
38804562
670869825
15779
88588674
20822573065
2605
5868164935
1070452
125725452
498586
325240481
156
665957283859
53895
4210966
4700749
146723807
3764139838369
2894087988246
85929762
5311875
996195
1032984902749
32693
...

result:

wrong answer 6th lines differ - expected: '136625731', found: '229759315'