QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563713#9285. Construct The Integerzjy0001WA 151ms4268kbC++171.1kb2024-09-14 15:20:492024-09-14 15:20:50

Judging History

This is the latest submission verdict.

  • [2024-09-14 15:20:50]
  • Judged
  • Verdict: WA
  • Time: 151ms
  • Memory: 4268kb
  • [2024-09-14 15:20:49]
  • Submitted

answer

#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
map<LL,int>ans;
int a[10],f[100000];
inline bool chk(LL n){
    LL c=n%10;
    while(n/=10)if(n%10!=c)return 0;
    return 1;
}
inline void dfs(int x){
    if(x==5){
        vector<int>d;
        do{
            int x=0;for(int i=0;i<5;++i)x=x*10+a[i];
            d.emplace_back(x);
        }while(next_permutation(a,a+5));
        sort(a,a+5);
        for(auto i:d)for(auto j:d)
            if(to_string(i).length()>=to_string(j).length())
                f[i]=__gcd(f[i],j);
    }
    else for(int i=x?a[x-1]:0;i<10;++i)a[x]=i,dfs(x+1);
}
inline void init(){
    iota(f+1,f+100000,1);
    dfs(0);
    for(int i=1;i<100000;++i)
        if(!ans.count(f[i]))ans[f[i]]=i;
        else ans[f[i]]=min(ans[f[i]],i);
}
inline void MAIN(){
    LL n;cin>>n;
    if(chk(n))cout<<n<<'\n';
    else cout<<(ans.count(n)?ans[n]:-1)<<'\n';
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    init();
    int t=1;cin>>t;while(t--)MAIN();
    return 0;
}
/*
*/

詳細信息

Test #1:

score: 100
Accepted
time: 146ms
memory: 4268kb

input:

2
12
2021

output:

48
-1

result:

ok 2 number(s): "48 -1"

Test #2:

score: 0
Accepted
time: 146ms
memory: 4036kb

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: 145ms
memory: 3972kb

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: 151ms
memory: 4036kb

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: -100
Wrong Answer
time: 146ms
memory: 3984kb

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
-1
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:

wrong answer 22nd numbers differ - expected: '5055555555', found: '-1'