QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#155894 | #6407. Classical A+B Problem | BUET_POTATOES# | WA | 1ms | 3608kb | C++20 | 2.5kb | 2023-09-02 12:13:14 | 2023-09-02 12:13:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
string num;
cin>>num;
for(int a = 1; a <= 9; a++){
for(int b = 1; b <= 9; b++){
if((a+b)%10 != num.back()-'0')
continue;
int acnt = 0, bcnt = 0;
bool Adone = false, Bdone = false;
int carry = 0;
bool ok = true;
for(int i = num.size()-1; i>=0; i--){
int s = num[i] - '0';
if(Adone){
if(s == carry){
carry = 0;
}
else{
ok = false;
break;
}
}
else if(Bdone){
if(s == carry){
Adone = true;
carry = 0;
}
else if(s == (carry+a)%10){
acnt++;
carry = (carry+a)/10;
}
else{
ok = false;
break;
}
}
else{
if(s == carry){
Adone = true;
Bdone = true;
carry = 0;
}
else if(s == (carry+a)%10){
acnt++;
carry = (carry+a)/10;
Bdone = true;
}
else if(s == (carry+a+b)%10){
acnt++;
bcnt++;
carry = (carry+a+b)/10;
}
else{
ok = false;
break;
}
}
}
if(carry != 0)
ok = false;
if(!ok) continue;
for(int i = 0; i<acnt; i++){
cout<<char(a+'0');
}
cout<<" ";
for(int i = 0; i<bcnt; i++){
cout<<char(b+'0');
}
cout<<'\n';
return;
}
}
}
/*
1
1332
*/
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int tc;
cin>>tc;
for(int cs = 1; cs <= tc; cs++){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3608kb
input:
6 2 786 1332 89110 2333333 10000000000000000000000000001
output:
1 1 777 9 333 999 2222222 111111 9999999999999999999999999999 2
result:
wrong answer Token parameter [name=x] equals to "2222222", doesn't correspond to pattern "[1-9]{1,5}" (test case 4)