QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#113014#6407. Classical A+B ProblemSoyTonyWA 2ms3760kbC++142.2kb2023-06-15 21:17:052023-06-15 21:17:06

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-15 21:17:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3760kb
  • [2023-06-15 21:17:05]
  • 提交

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];
struct BigIntager{
    int siz;
    int a[maxn];
    BigIntager(){
        siz=0;
        memset(a,0,sizeof(a));
    }
    bool operator<(const BigIntager& rhs)const{
        if(siz!=rhs.siz) return siz<rhs.siz;
        for(int i=siz;i>=1;--i){
            if(a[i]!=rhs.a[i]) return a[i]<rhs.a[i];
        }
        return false;
    }
    BigIntager operator-(const BigIntager& rhs)const{
        BigIntager res;
        res.siz=siz;
        int now=0;
        for(int i=1;i<=siz;++i){
            res.a[i]=a[i]-now-((i<=rhs.siz)?rhs.a[i]:0);
            if(res.a[i]<0) res.a[i]+=10,now=1;
            else now=0;
        }
        while(!res.a[res.siz]) --res.siz;
        return res;
    }
    bool check(){
        for(int i=1;i<=siz;++i){
            if(a[i]!=a[1]) return false;
        }
        return true;
    }
    inline void output(){
        for(int i=siz;i>=1;--i) printf("%d",a[i]);
    }
}A,B,C;
int main(){
    t=read();
    while(t--){
        scanf("%s",s+1);
        n=strlen(s+1);
        A.siz=n;
        for(int i=1;i<=n;++i) A.a[i]=s[n-i+1]-'0';
        B.siz=n;
        bool chk=0;
        for(int i=1;i<=9;++i){
            for(int j=1;j<=n;++j) B.a[j]=i;
            if(A<B) continue;
            C=A-B;
            if(C.check()){
                B.output();
                printf(" ");
                C.output();
                printf("\n");
                chk=1;
                break;
            }
        }
        if(!chk&&n>1){
            B.siz=n-1;
            for(int i=1;i<=9;++i){
                for(int j=1;j<n;++j) B.a[j]=i;
                if(A<B) continue;
                C=A-B;
                if(C.check()){
                    B.output();
                    printf(" ");
                    C.output();
                    printf("\n");
                    chk=1;
                    break;
                }
            }
        }
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

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: 2ms
memory: 3748kb

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
1 9
11111111 2222
333 2
77777 2
88888888888888888888888888888888888888888888 222222222222222222222
55555555555555555555 222222
66666666666666666666666 555...

result:

wrong answer Token parameter [name=y] equals to "88888888888", doesn't correspond to pattern "[1-9]{1,2}" (test case 77)