QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#112916 | #6407. Classical A+B Problem | SoyTony | WA | 1ms | 3620kb | C++14 | 2.1kb | 2023-06-15 11:29:09 | 2023-06-15 11:29:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+10;
inline int read(){
int x=0,w=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return x*w;
}
int t;
int n;
char s[maxn];
int main(){
t=read();
while(t--){
scanf("%s",s+1);
n=strlen(s+1);
bool chk1=1;
for(int i=2;i<n;++i){
if(s[i]!='0') chk1=0;
}
if(chk1&&s[1]=='1'){
for(int i=1;i<n;++i) printf("9");
printf(" %c\n",s[n]+1);
continue;
}
int cnt=0;
for(int i=1;i<=n;++i){
if(s[i]!=s[i-1]) ++cnt;
}
if(cnt==1){
for(int i=1;i<=n;++i) printf("1");
printf(" ");
for(int i=1;i<=n;++i) printf("%d",s[i]-'1');
printf("\n");
}
else if(cnt==2&&s[n]!='0'){
for(int i=1;i<=n;++i){
if(i>1&&s[i]!=s[i-1]){
for(int j=1;j<=n;++j) printf("%c",s[1]);
printf(" ");
for(int j=i;j<=n;++j) printf("%d",s[n]-s[1]);
printf("\n");
break;
}
}
}
else if(cnt==3||(cnt==2&&s[n]=='0')){
int x=(s[1]=='1')?9:s[1]-'1',y=s[n]-'0'+10-x;
for(int i=1;i<n+(s[1]!='1');++i) printf("%d",x);
printf(" ");
for(int i=1;i<n;++i) printf("%d",y);
printf("\n");
}
else{
int x=(s[2]=='0')?9:s[1]-'0',y=s[n]-'0'+10-x;
for(int i=1;i<n+(x!=9);++i) printf("%d",x);
printf(" ");
bool chk2=0;
for(int i=1;i<=n;++i){
if(s[i]!=s[i-1]){
if(!chk2) chk2=1;
else{
for(int j=i;j<=n;++j) printf("%d",y);
printf("\n");
break;
}
}
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3620kb
input:
6 2 786 1332 89110 2333333 10000000000000000000000000001
output:
1 1 666 1010 999 333 88888 2222 2222222 111111 9999999999999999999999999999 2
result:
wrong answer Token parameter [name=y] equals to "1010", doesn't correspond to pattern "[1-9]{1,3}" (test case 2)