QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563702#9285. Construct The Integerzjy0001WA 1ms3648kbC++171.2kb2024-09-14 15:15:232024-09-14 15:15:24

Judging History

This is the latest submission verdict.

  • [2024-09-14 15:15:24]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3648kb
  • [2024-09-14 15:15:23]
  • 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;
inline bool chk(int n){
    int c=n%10;
    while(n/=10)if(n%10!=c)return 0;
    return 1;
}
inline void init(){
    vector<int>f(1000);
    for(int x=0;x<10;++x)
        for(int y=0;y<10;++y)
            for(int z=0;z<10;++z)if(x||y||z)
                f[x*100+y*10+z]=x*100+y*10+z,
                f[x*100+y*10+z]=__gcd(f[x*100+y*10+z],x*100+z*10+y),
                f[x*100+y*10+z]=__gcd(f[x*100+y*10+z],y*100+x*10+z),
                f[x*100+y*10+z]=__gcd(f[x*100+y*10+z],y*100+z*10+x),
                f[x*100+y*10+z]=__gcd(f[x*100+y*10+z],z*100+x*10+y),
                f[x*100+y*10+z]=__gcd(f[x*100+y*10+z],z*100+y*10+x);
    for(int i=1;i<1000;++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: 1ms
memory: 3608kb

input:

2
12
2021

output:

48
-1

result:

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

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3648kb

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
-1
666666
2
-1
-1
44
6666666
333333
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
888
-1
-1
-1
-1
88888888
-1
88
-1
-1
-1
555
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11
-1
-1
-1

result:

wrong answer 7th numbers differ - expected: '8088', found: '-1'