QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#562711 | #9285. Construct The Integer | ship2077 | WA | 107ms | 4416kb | C++23 | 1.3kb | 2024-09-13 20:11:39 | 2024-09-13 20:11:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=1e6+5,lim=1e6;
int g[M],ans[M];
void init(){
auto dfs=[&](auto self,auto x)->void {
if (x>lim) return;
vector<int>vec;
for (int s=x;s;s/=10)
vec.emplace_back(s%10);
sort(vec.begin(),vec.end());
while (vec.size()<6){
if (!vec.empty()){ int cur=0;
if (!vec[0]) for (int i=1;i<vec.size();i++)
if (vec[i]) {swap(vec[0],vec[i]);break;}
for (auto x:vec) cur=cur*10+x;
g[cur]=__gcd(g[cur],x);
}
vec.insert(vec.begin(),0);
}
for (int d=!x;d<=9;d++)
self(self,x*10+d);
};
dfs(dfs,0);
for (int i=1;i<=lim;i++)
if (!ans[g[i]]) ans[g[i]]=i;
}
void solve(){
long long n;scanf("%lld",&n);
if (n<=lim&&ans[n]) return printf("%d\n",ans[n]),void();
if (n==18) return puts("2022222222"),void();
if (n==27) return puts("3033333333"),void();
if (n==36) return puts("4044444444"),void();
if (n==45) return puts("5055555555"),void();
if (n==54) return puts("6066666666"),void();
if (n==72) return puts("8088888888"),void();
if (n==81) return puts("9099999999"),void();
string str=to_string(n);bool flag=1;
for (int i=1;i<str.length();i++) flag&=str[i]==str[0];
if (flag) return printf("%lld\n",n),void(); puts("-1");
}
int main(){ init();
int T;scanf("%d",&T);
while (T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 106ms
memory: 4208kb
input:
2 12 2021
output:
48 -1
result:
ok 2 number(s): "48 -1"
Test #2:
score: 0
Accepted
time: 105ms
memory: 4416kb
input:
50 162281868021198482 843590795441798975 22222 149588437607469906 802011151087104980 6059547534408460 24 666666 2 76 29 44 6666666 333333 694875412087041404 203911016125660313 33333333333333333 621646568444724049 363434583954291856 33333333333333 7777777777777777 308242055812053607 65243634304254533...
output:
-1 -1 22222 -1 -1 -1 8088 666666 2 -1 -1 44 6666666 333333 -1 -1 33333333333333333 -1 -1 33333333333333 7777777777777777 -1 -1 -1 888 -1 4444444444 -1 3333333333333333 88888888 888888888888 88 -1 3333333333333 -1 555 -1 48888 222222222222 -1 -1 -1 -1 -1 -1 -1 11 -1 -1 55555555555555555
result:
ok 50 numbers
Test #3:
score: 0
Accepted
time: 101ms
memory: 4140kb
input:
50 841731922341882973 172755266467187037 129493702112701195 90 273793122414069242 593694707008455288 502545216673419533 721595990997982386 93377610984612549 87 863812025013802109 234122432773362066 123027939432443575 88888 47 222222222222222222 852841820206347862 74 423472610938208849 94 15762310812...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 88888 -1 222222222222222222 -1 -1 -1 -1 -1 -1 -1 22222222 -1 -1 -1 -1 -1 -1 -1 -1 333333333333333 -1 -1 -1 1111111111111111 -1 -1 -1 4 333333333 -1 33333333 -1 1 444444444444444444 5055 -1 4444444444444444
result:
ok 50 numbers
Test #4:
score: 0
Accepted
time: 105ms
memory: 4112kb
input:
50 66666666 89 11111111111111111 89013034181000726 33 285627919192884437 8888888888 425171425350891250 71 7 987944414171602593 301305598619697018 193193702519217107 413499651741453076 476551385483571548 13 668044926137832393 66666666666666 536187734191891003 386045016440405474 592806051753396502 805...
output:
66666666 -1 11111111111111111 -1 33 -1 8888888888 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 66666666666666 -1 -1 -1 -1 4444444 666666666666666 -1 -1 -1 666666666666666666 -1 -1 -1 -1 -1 33 -1 -1 -1 -1 77777777777 -1 -1 8888888 -1 -1 -1 -1 -1 -1 -1 66
result:
ok 50 numbers
Test #5:
score: 0
Accepted
time: 105ms
memory: 4140kb
input:
50 21839873092357856 640219260799980486 522525742014723888 725988133037119616 290913044663852094 555555 333 85 11111111 631169318889705610 555555555555 69 323842199157642120 333333333333333333 78 4444444444444 99 11111111111 174059246927999752 377574503599716306 777777777 45 77777777777777 471255439...
output:
-1 -1 -1 -1 -1 555555 333 -1 11111111 -1 555555555555 -1 -1 333333333333333333 -1 4444444444444 99 11111111111 -1 -1 777777777 5055555555 77777777777777 -1 -1 -1 -1 -1 666 -1 3699 11111 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 222222 777
result:
ok 50 numbers
Test #6:
score: 0
Accepted
time: 107ms
memory: 4372kb
input:
50 134845565732593935 935387048910748709 664860202421625603 111111111111 94225248889089695 879054556667480931 83 256931203846046588 92 3333333333 643572951492602142 49 822981260158260819 82526944128792584 77 179102579989215254 444444444444444 903288965370689433 799584023203226863 495718727325977077 ...
output:
-1 -1 -1 111111111111 -1 -1 -1 -1 -1 3333333333 -1 -1 -1 -1 77 -1 444444444444444 -1 -1 -1 9 55555555555 66666666666 -1 -1 7077 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 444444444444 111111111111111111 -1 777777 -1 1111111 -1 -1 -1 5555555 -1 -1
result:
ok 50 numbers
Test #7:
score: 0
Accepted
time: 105ms
memory: 4400kb
input:
50 521060787741107580 23 676105575462225385 381451598031262925 163853609803189968 6666666666 444444444 5413279537561410 8888 627586599810900678 26 42 55555555555555 43 916143781173401889 84324828731964774 57 502764983190081253 563324731189331234 53 993638134797830048 3 52966605322057444 333333333333...
output:
-1 -1 -1 -1 -1 6666666666 444444444 -1 8888 -1 -1 -1 55555555555555 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 333333333333 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 11111111111111 -1 -1 -1 44444444 -1 -1 -1
result:
ok 50 numbers
Test #8:
score: 0
Accepted
time: 105ms
memory: 4396kb
input:
50 888888888888888 56 877835694720649559 952720572201731456 335408917861649366 66666 2222222222222 2222222222222222 60 787629613935422754 776076510839296560 630192867080657053 88888888888 77 371026816893229896 540950482791116710 1111 438538728083004091 1111111111111 692477168467510300 14875591187121...
output:
888888888888888 -1 -1 -1 -1 66666 2222222222222 2222222222222222 -1 -1 -1 -1 88888888888 77 -1 -1 1111 -1 1111111111111 -1 -1 -1 111 444 -1 44444444444 -1 -1 -1 55555555 222 7777777777 -1 555555555555555555 -1 -1 -1 66 -1 3333 -1 -1 77777777 -1 22222222222 -1 -1 -1 8088888888 -1
result:
ok 50 numbers
Test #9:
score: 0
Accepted
time: 105ms
memory: 4196kb
input:
50 59 51 661302813816248549 22 192583020404011827 17 44444444444444 91 586662754350034562 398400101471708497 101765673897273715 950257034940091202 675282347327966568 262324075672299484 55 116841977139981012 907267074306890738 731741654713115120 33333333333 95 111111111 49465410047628729 676526945279...
output:
-1 -1 -1 22 -1 -1 44444444444444 -1 -1 -1 -1 -1 -1 -1 55 -1 -1 -1 33333333333 -1 111111111 -1 -1 88888888888888 -1 666666666666 -1 7777 -1 -1 -1 666666666 -1 -1 -1 -1 -1 -1 6666666666666 -1 -1 -1 6 -1 3333333 -1 -1 -1 -1 5
result:
ok 50 numbers
Test #10:
score: 0
Accepted
time: 105ms
memory: 4108kb
input:
50 52 575309381208032699 5555555555555 266726083774034829 542826291792345757 7777777 851387910588959345 769483004587345130 66666666666666666 444444 753084815602287766 21314793613364329 555555555555555 5555 55555 802650828045480305 59132663174616906 18 107332661275127473 33333 22222222222222 70482262...
output:
-1 -1 5555555555555 -1 -1 7777777 -1 -1 66666666666666666 444444 -1 -1 555555555555555 5555 55555 -1 -1 288 -1 33333 22222222222222 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 44444 -1 -1 -1 -1 -1 555555555 -1 -1 8888888888888888 -1 -1 -1 -1 -1 -1 -1
result:
ok 50 numbers
Test #11:
score: -100
Wrong Answer
time: 105ms
memory: 4140kb
input:
50 777777777777777 838885201040309576 7777777777777 349993004923079131 961905130001849922 44 888888888 494205937842636532 88 665229069533206603 676042795298310688 704087678909665196 148049062628894820 81 58 615812229161736595 758551024807498420 819875141880896223 922348607469188267 8888888888888 168...
output:
777777777777777 -1 7777777777777 -1 -1 44 888888888 -1 88 -1 -1 -1 -1 9099999999 -1 -1 -1 -1 -1 8888888888888 -1 -1 -1 -1 2222 -1 -1 888888888888888888 -1 5555555555 5555555555555555 -1 6066666666 -1 -1 -1 -1 -1 -1 111111111111111 -1 777777777777777777 -1 -1 77777 -1 99 -1 55 -1
result:
wrong answer 33rd numbers differ - expected: '222888888', found: '6066666666'