QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#631166 | #8932. Bingo | woodie_0064# | WA | 130ms | 9228kb | C++17 | 1.8kb | 2024-10-11 22:28:18 | 2024-10-11 22:28:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int T;
int n, num;
using i64 = long long;
void work(){
string s;
int m;cin >> s >> m;
auto accumstr = [] (const string &x,const string &y) {
string s = x,t = y;
int n = s.size(),m = t.size();
reverse(s.begin(),s.end());
reverse(t.begin(),t.end());
int i = 0,j = 0,pre = 0;
string now = "";
while(i < n || j < m || pre) {
if(i < n) {
pre += s[i] - '0';
i += 1;
}
if(j < m) {
pre += t[j] - '0';
j += 1;
}
now += ('0' + pre % 10);
pre /= 10;
}
reverse(now.begin(),now.end());
return now;
};
auto accum = [&] (const string &s,int p) {
return accumstr(s,to_string(p));
};
s = accum(s,1);
i64 p = 0;
for(int i = 0;i < (int)s.size();i++) p = (p * 10 + s[i] - '0') % m;
auto cmp = [&] (const string &x,const string &y) {
if(x.size() > y.size()) return 1;
if(x.size() < y.size()) return 0;
if(x > y) return 1;
return 0;
};
string M = to_string(m);
if(s.find(M) != s.npos) {
cout << s << '\n';
return;
}
string ans = accum(s,(m - p) % m);
auto change = [&] (const string &s,int x) {
string now = s;
reverse(now.begin(),now.end());
while(now.size() < (int)M.size() + x) now += '0';
reverse(now.begin(),now.end());
int fir = now.size() - x - (int)M.size();
for(int i = 0;i < (int)M.size();i++) now[fir + i] = M[i];
return now;
};
for(int i = 0;i < 20;i++) {
string now = change(s,i);
if(cmp(s,now)) continue;
int len = now.size();
for(int j = 0;j < i;j++) now[len - 1 - j] = '0';
if(cmp(ans,now)) swap(ans,now);
}
cout << ans << '\n';
}
int main(){
// freopen("test.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
cin >> T;
while(T--){
work();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1
output:
9 13 10 251 1370 3
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 96ms
memory: 3856kb
input:
100000 3196282243 28 7614814237 33 2814581084 97 1075124401 58 7822266214 100 1767317768 31 7189709841 75 9061337538 69 6552679231 38 9946082148 18 5497675062 54 7787300351 65 4310767261 68 4811341953 100 3265496130 31 8294404054 62 2845521744 90 1114254672 26 6442013672 13 3744046866 40 3289624367 ...
output:
3196282244 7614814251 2814581097 1075124424 7822266300 1767317769 7189709850 9061337569 6552679238 9946082160 5497675063 7787300365 4310767268 4811342000 3265496131 8294404062 2845521790 1114254674 6442013673 3744046867 3289624375 6477935360 1292587551 5504674689 2898829180 7882736025 2846033387 923...
result:
ok 100000 lines
Test #3:
score: 0
Accepted
time: 120ms
memory: 3572kb
input:
100000 81390699571930639918 18 48435143897560239761 20 51628960043353404809 75 47871552664477358704 12 59273263135375104780 37 76916933870890715781 71 23716799616473386311 99 68152894841119747794 73 87132912926681514765 23 14152130046962902029 76 46737628796812988809 24 40572731276115804589 44 26281...
output:
81390699571930639920 48435143897560239780 51628960043353404825 47871552664477358712 59273263135375104781 76916933870890715782 23716799616473386312 68152894841119747819 87132912926681514784 14152130046962902060 46737628796812988824 40572731276115804612 26281826064684565884 31440839508345860244 322404...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 35ms
memory: 3908kb
input:
3000 7455619882273084107817302538515753878442453229160411398764628307708900718973255504130291326067024207515690930909093270962092669445260372092520050302437090344417275699335988483584829739890137897388569114922455183012826259500289116227868472807384706143668392682061768042886347879057062217228560088...
output:
745561988227308410781730253851575387844245322916041139876462830770890071897325550413029132606702420751569093090909327096209266944526037209252005030243709034441727569933598848358482973989013789738856911492245518301282625950028911622786847280738470614366839268206176804288634787905706221722856008829738...
result:
ok 3000 lines
Test #5:
score: 0
Accepted
time: 35ms
memory: 3828kb
input:
30 744510720233756810275704474604569745531035132640480367036243214564743016462196305795005354253050610470663589619681077004760475741831076832118956334526511556189341001350810877421229216943948759000423729628987372479322027768925371301094347427331321252113757179047865411408129452046409100799804797802...
output:
744510720233756810275704474604569745531035132640480367036243214564743016462196305795005354253050610470663589619681077004760475741831076832118956334526511556189341001350810877421229216943948759000423729628987372479322027768925371301094347427331321252113757179047865411408129452046409100799804797802630...
result:
ok 30 lines
Test #6:
score: 0
Accepted
time: 83ms
memory: 3816kb
input:
30 105809806761073271256887955844712146828376005200803410278562148742151831107043468856832007772397456498455138267388212588031778017994162605374749926516470689670500596864238694115641474868867283410369346289694466106606968664652794746652928273585660548259964572696052192486090603389036781439603103550...
output:
105809806761073271256887955844712146828376005200803410278562148742151831107043468856832007772397456498455138267388212588031778017994162605374749926516470689670500596864238694115641474868867283410369346289694466106606968664652794746652928273585660548259964572696052192486090603389036781439603103550889...
result:
ok 30 lines
Test #7:
score: 0
Accepted
time: 99ms
memory: 9228kb
input:
3 6662543589767466036246495639712784214474800991502397969575900509392047845463534421346617412312874112216857204224202275839595569716788606196210901109061789975871578517491994493982488930577332027254701120487517960025453194037512904252125592964194448410502834649100626540616447074805775399798416968996...
output:
666254358976746603624649563971278421447480099150239796957590050939204784546353442134661741231287411221685720422420227583959556971678860619621090110906178997587157851749199449398248893057733202725470112048751796002545319403751290425212559296419444841050283464910062654061644707480577539979841696899669...
result:
ok 3 lines
Test #8:
score: 0
Accepted
time: 35ms
memory: 8440kb
input:
3 2256815269292565600156592193265637162224642022040502404316754847487816065925979403817785481924286639616366305614486960621565248701689067791722502719550041520364571182248705842386853601004910941840817347333021115646730530046766144383475985584378580286873533357460940983992705079090280123003684728456...
output:
225681526929256560015659219326563716222464202204050240431675484748781606592597940381778548192428663961636630561448696062156524870168906779172250271955004152036457118224870584238685360100491094184081734733302111564673053004676614438347598558437858028687353335746094098399270507909028012300368472845644...
result:
ok 3 lines
Test #9:
score: 0
Accepted
time: 53ms
memory: 3704kb
input:
3000 1207038022435933497172867897608582834259296434513291920701948658102620971426545864576004516739100232550813726497575096647995838994831563955620812388750705335658097405810012745415674568116125791908722845971700778242654229220680637480729636188583094437004798976145084978037723467998680024921907308...
output:
120703802243593349717286789760858283425929643451329192070194865810262097142654586457600451673910023255081372649757509664799583899483156395562081238875070533565809740581001274541567456811612579190872284597170077824265422922068063748072963618858309443700479897614508497803772346799868002492190730846477...
result:
ok 3000 lines
Test #10:
score: 0
Accepted
time: 81ms
memory: 3532kb
input:
3000 5187892603368075393366934145761537065733813260653168421673419435040503882271162798390450740194183522231455416476478191713916592902549286209613912969893791259298651451942049981218891583442405056389087471219061688102180898906527834095792495015886014196868276353417569226991138737552057896779213092...
output:
518789260336807539336693414576153706573381326065316842167341943504050388227116279839045074019418352223145541647647819171391659290254928620961391296989379125929865145194204998121889158344240505638908747121906168810218089890652783409579249501588601419686827635341756922699113873755205789677921309299202...
result:
ok 3000 lines
Test #11:
score: 0
Accepted
time: 89ms
memory: 3604kb
input:
100000 6826989967 99 7841681495 15 3418122299 23 1701647194 72 9299999983 93 1881999956 82 1123299980 33 3771371885 19 1309999986 31 3877999989 78 9357331671 75 7627599957 76 1678299927 83 8841256998 57 8260576238 25 1799999994 18 3154099999 41 9276743997 44 4591431162 68 3499999996 35 8003134976 35...
output:
6826989968 7841681500 3418122300 1701647200 9299999993 1881999958 1123300000 3771371900 1310000000 3878000000 9357331675 7627599958 1678299983 8841257000 8260576250 1800000000 3154100000 9276744000 4591431168 3500000000 8003135000 5504020000 1255390000 4126500000 6300000000 7478000000 5763230000 666...
result:
ok 100000 lines
Test #12:
score: 0
Accepted
time: 130ms
memory: 3564kb
input:
100000 4044835167 404504 8453174053 180343 2345170166 345322 8666517296 666590 8889410862 895103 6539631279 398778 8763575235 742233 3347416626 347507 6020459808 204689 2518651157 186574 1970898496 970950 3644468912 446818 2284133423 265848 4297464212 297490 9673618882 687317 2262910438 26292 460442...
output:
4045040000 8453180343 2345322000 8666590000 8889510300 6539877800 8763742233 3347507000 6020468900 2518657400 1970950000 3644681800 2284166016 4297490000 9673687317 2262920000 4604460456 5602450000 9441133300 9662607060 1137808896 5763236104 1265770000 9709569000 2270400726 8750103140 4985572109 607...
result:
ok 100000 lines
Test #13:
score: -100
Wrong Answer
time: 113ms
memory: 3564kb
input:
30000 2258423372953702192256514103021059999999999999999999999999999999999999999999999999999999999942889028 410302106 9236851817519460666717196537240869999999999999999999999999999999999999999999999999999999999883401708 653724087 528305359636938134447446654161626435106860486355385047059638284973309516...
output:
2258423372953702192256514103021060000000000000000000000000000000000000000000000000000000000037762692 9236851817519460666717196537240870000000000000000000000000000000000000000000000000000000000429930002 52830535963693813444744665416162643510686048635538504705963828497330951691000000000000000001736371...
result:
wrong answer 1st lines differ - expected: '225842337295370219225651410302...0000000000000000000000000000000', found: '225842337295370219225651410302...0000000000000000000000037762692'