QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583184 | #6407. Classical A+B Problem | huaxiamengjin# | WA | 0ms | 3768kb | C++14 | 1.4kb | 2024-09-22 18:51:49 | 2024-09-22 18:51:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char s[100100];
int a[100100];
void solve(){
scanf("%s",s+1);
int n=strlen(s+1);
int pre=0;
for (int i=1;i<=s[1]-'0';i++){
int now=0,pre=0,fl=0,wei=0,tmp=0;
for (int j=1;j<=n;j++)
a[j]=s[j]-'0';
for (int j=n;j;j--){
now=a[j]-i;
if(now<0)now+=10,a[j-1]--;
// cout<<now<<" ""***\n";
if(tmp!=0&&now!=0&&tmp!=now){
fl=1;break;
}else if(tmp==0){
if(now==0){
fl=1;break;
}else tmp=now,wei=j;
}else if(now==tmp)wei=j;
}
// cout<<i<<" "<<wei<<" "<<tmp<<" "<<fl<<"\n";
if(fl==0&&wei!=0){
for (int j=1;j<=n;j++)
cout<<i;cout<<" ";
for (int j=wei;j<=n;j++)
cout<<tmp;cout<<"\n";
return ;
}
}
if(s[1]!='1')return ;
for (int i=s[2]-'0';i<=9;i++){
int now=0,pre=0,fl=0,wei=0,tmp=0;
for (int j=1;j<=n;j++)
a[j]=s[j]-'0';
a[2]=a[1]*10+a[2];a[1]=0;
for (int j=n;j>=2;j--){
now=a[j]-i;
if(now<0)now+=10,a[j-1]--;
// cout<<now<<" "<<tmp<<"***\n";
if(tmp!=0&&now!=0&&tmp!=now){
fl=1;break;
}else if(tmp==0){
if(now==0){
fl=1;break;
}else tmp=now,wei=j;
}else if(now==tmp)wei=j;
}
// cout<<tmp<<"&&&&&&";
if(fl==0&&wei!=0){
for (int j=2;j<=n;j++)
cout<<i;cout<<" ";
for (int j=wei;j<=n;j++)
cout<<tmp;cout<<"\n";
return ;
}
}
}
int main(){
int T;cin>>T;
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
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: 3768kb
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)