QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603515#9408. Hero of the Kingdomucup-team3474AC ✓94ms3712kbC++201.1kb2024-10-01 16:59:432024-10-01 16:59:47

Judging History

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

  • [2024-10-01 16:59:47]
  • 评测
  • 测评结果:AC
  • 用时:94ms
  • 内存:3712kb
  • [2024-10-01 16:59:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
// ll a[N],b[N];
// char s[N];

void __(){
    ll p,a,b,q,c,d,m,t;
    cin>>p>>a>>b>>q>>c>>d>>m>>t;
    if(m<p){
        cout<<m<<"\n";
        return;
    }
    while(t>0){
        ll nowcnt=m/p;
        ll ad=nowcnt*(q-p);
        ll need=p*(nowcnt+1)-m;
        ll needtimes=(need+ad-1)/ad;
        ll needt=needtimes*(b+d+(a+c)*nowcnt);
        // cout<<nowcnt<<" "<<needt<<endl;
        if(t>=needt){
            t-=needt;
            m+=ad*needtimes;
        }else{
            ll l=0,r=1e10;
            while(l<r){
                ll mid=l+r+1>>1;
                ll cnttm=(mid+nowcnt-1)/nowcnt;
                ll tm=cnttm*(b+d)+(a+c)*mid;
                if(tm>t) r=mid-1;
                else l=mid;
            }
            m+=(q-p)*l;
            break;
        }
    }
    cout<<m<<"\n";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        __();
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 3584kb

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
136625731
586
25929035
17864
7905961573
38782804
670869825
16635
88588674
4502
3995
6379706119
1070452
134333292
495166
324797075
156
598405696216
53895
3503164
4727693
124349483
3764139838369
2840566939118
85930522
4319452
996195
54156125533
32693
216299285...

result:

ok 500 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

500
9859 96 66
18107 8 30
9950 322595515
6685 7 72
14282 47 17
710156469 985188306
786 32 8
2933 21 57
2530 475357775
1535 61 92
9610 100 90
6051 234173340
235 86 81
5512 27 68
9835 714622972
687 56 37
3582 70 100
629389147 226582349
9168 61 11
12755 16 97
664916091 247483035
2739 64 90
5897 44 9
38...

output:

25584109990
139311465421
19256441236
11744948201
33372232765
5835380797
12193720615
13079297133
19440097830
56779063033
331648541482
2723772225
237117790
10437118404
395216971
31345418497
32698954033
11916385660
17791542518
6032738252
36336942872
32227281718
49751088535
16843534938
33842489055
27371...

result:

ok 500 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

500
31708734 1 0
31708735 1 0
31708734 1000000000
71574353 1 0
71574354 1 0
71574353 1000000000
46622902 1 0
46622903 1 0
46622902 1000000000
76021915 1 0
76021916 1 0
76021915 1000000000
89054722 1 0
89054723 1 0
89054722 1000000000
88299900 1 0
88299901 1 0
88299900 1000000000
82784529 1 0
8278453...

output:

531708734
571574353
546622902
576021915
589054722
588299900
582784529
582129869
551025857
568544853
526715316
569267326
559579715
530370885
527159843
555075715
541540909
527571311
523397790
552716884
520753977
538383098
589249550
571463305
564892769
550316979
598655625
576520305
522745720
540557074
...

result:

ok 500 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

500
1 1 8
8 1 5
30 469496529
10 10 4
17 8 8
74 14
6 6 1
16 10 2
73 196513513
9 10 8
19 8 3
21 48
9 8 6
17 5 3
5 57
5 3 1
12 5 7
30 98
6 2 8
9 8 4
38 9
2 8 4
4 1 8
92 767092959
8 8 8
17 3 7
99 33
9 9 7
19 7 6
87 81
4 7 2
10 9 10
32 25561344
5 3 7
13 1 0
55 64
4 1 6
13 1 10
23 869480511
7 2 1
11 2 1
8...

output:

1643237472
74
122820983
41
5
100
38
170465138
108
127
9585470
151
3912661094
722399361
92971888
114793872
81501035
2
38095692
118
35
20
36
53133573
102
68
49549067
40
130361099
115493267
255885870
92
17
46571659
97
78
7783122
302931422
133654535
34001068
100
3462678
48960994
160399289
447095016
1058...

result:

ok 500 lines

Test #6:

score: 0
Accepted
time: 93ms
memory: 3616kb

input:

500
999967811 1 0
1000000000 1 0
999967811 1000000000
999969915 1 0
1000000000 1 0
999969915 1000000000
999967473 1 0
1000000000 1 0
999967473 1000000000
999969851 1 0
1000000000 1 0
999969851 1000000000
999969545 1 0
1000000000 1 0
999969545 1000000000
999967977 1 0
1000000000 1 0
999967977 1000000...

output:

16095499967811
15043499969915
16264499967473
15075499969851
15228499969545
16012499967977
16205999967590
15347499969307
15977999968046
16261499967479
16134999967732
16436499967129
16170999967660
15717499968567
15267499969467
16202999967596
16078999967844
15677999968646
15922999968156
15056999969888
...

result:

ok 500 lines

Test #7:

score: 0
Accepted
time: 94ms
memory: 3584kb

input:

500
32242 1 0
32243 1 0
32242 1000000000
30507 1 0
30508 1 0
30507 1000000000
30104 1 0
30105 1 0
30104 1000000000
31357 1 0
31358 1 0
31357 1000000000
31645 1 0
31646 1 0
31645 1000000000
32632 1 0
32633 1 0
32632 1000000000
31676 1 0
31677 1 0
31676 1000000000
32647 1 0
32648 1 0
32647 1000000000
...

output:

500032242
500030507
500030104
500031357
500031645
500032632
500031676
500032647
500030881
500031392
500032808
500032799
500032389
500032220
500030030
500031592
500031157
500031354
500031417
500032692
500032050
500031094
500030773
500030191
500031507
500032455
500032786
500032597
500031281
500030551
...

result:

ok 500 lines

Extra Test:

score: 0
Extra Test Passed