QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#427717 | #6407. Classical A+B Problem | liuzhenhao09# | WA | 0ms | 3952kb | C++20 | 1.2kb | 2024-06-01 15:12:13 | 2024-06-01 15:12:13 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,len;
char s[5010];
signed main(){
scanf("%lld",&T);
while(T--){
scanf("%s",s + 1);
len = strlen(s + 1);
int tmp = s[len] - '0';
for(int x = 1; x <= 9; x++){
int y = (tmp + 10 - x) % 10;
if(!y) continue;
int U = 0;
bool flag = 1,oo = 1;
int lenx = len,leny = len;
for(int i = len; i >= 1; i--){
if(flag){
if((x + y + U) % 10 == s[i] - '0') U = (x + y + U) / 10;
else if((x + U) % 10 == s[i] - '0'){
leny = len - i;
flag = 0;
U = (x + U) / 10;
}
else if(U % 10 == s[i] - '0'){
lenx = len - i,leny = len - i;
flag = 0;
U = 0;
}
else{
oo = 0;
break;
}
}
else{
if((x + U) % 10 == s[i] - '0') U = (x + U) / 10;
else if(U % 10 == s[i] - '0'){
lenx = len - i;
U = 0;
}
else{
oo = 0;
break;
}
}
}
if(oo){
for(int i = 1; i <= lenx; i++) printf("%lld",x);
printf(" ");
for(int i = 1; i <= leny; i++) printf("%lld",y);
printf("\n");
break;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3952kb
input:
6 2 786 1332 89110 2333333 10000000000000000000000000001
output:
1 1 777 9 333 999 88888 222 2222222 111111 9999999999999999999999999999 2
result:
ok ok (6 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3904kb
input:
100 854 77777777781111111111111111110 44444450 11111111111111333 2310 5 333333333333333333333343332 888999 10 11113333 335 77779 88888888888888888888889111111111111111111110 55555555555555777777 72222222222222222222221 666 5777 1111555555 444444444544444444443 88888888888891111111111110 673332 97 77...
output:
777 77 77777777777777777777777777777 3333333333333333333 44444444 6 11111111111111111 222 2222 88 1 4 333333333333333333333333333 9999 888888 111 11 99 11111111 2222 333 2 77777 2 88888888888888888888888888888888888888888888 222222222222222222222 55555555555555555555 222222 66666666666666666666666 5...
result:
wrong answer x + y > n (test case 9)