QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583194 | #6407. Classical A+B Problem | huaxiamengjin# | WA | 0ms | 3816kb | C++14 | 1.4kb | 2024-09-22 18:54:24 | 2024-09-22 18:54:30 |
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 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=max(s[2]-'0',1);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: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
6 2 786 1332 89110 2333333 10000000000000000000000000001
output:
333 999 9999999999999999999999999999 2
result:
wrong answer Token parameter [name=x] equals to "333", doesn't correspond to pattern "[1-9]{1,1}" (test case 1)