UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215165#2656. addnaroto202201ms1240kbC++1.7kb2024-11-26 21:44:092024-11-26 23:06:01

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int MN=1e4+5;
ll n;
char ch[MN];
class gaojing{
    public:
    int a[MN];
    gaojing(){}
    void clear(){memset(a,0,sizeof(a));}
    void print(){if(a[0]==0)putchar('0');else for(int i=a[0]; i>=1; i--)putchar(a[i]+'0');}
    short cmp(const gaojing& x){if(a[0]>x.a[0])return 1;if(a[0]<x.a[0])return -1;for(int i=a[0]; i>=1; i--){if(a[i]>x.a[i]) return 1;if(a[i]<x.a[i]) return -1;}return 0;}
    bool operator == (const gaojing& x){return cmp(x)==0;}
    gaojing operator + (const gaojing& x){gaojing a=*this,c;c.clear();c.a[0]=max(a.a[0],x.a[0]);for(int i=1; i<=c.a[0]; i++){c.a[i]+=a.a[i]+x.a[i];if(c.a[i]>9){c.a[i]-=10;a.a[i+1]++;if(i==c.a[0])c.a[0]++;}}while(c.a[c.a[0]]==0&&c.a[0])c.a[0]--;return c;}
};
void write(ll n){if(n<0){putchar('-');write(-n);return;}if(n>9)write(n/10);putchar(n%10+'0');}
ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
int main(){
    scanf("%s",ch+1);n=strlen(ch+1);
    for(int x=1,y; x<=n/2; x++){
        if(x>=(n-x)/2) y=x+(n-x)/2;
        else y=n-x-1;
        gaojing a,b,c;a.a[0]=x;b.a[0]=y-x;c.a[0]=n-y;
        for(int i=x,j=1; i>=1; i--,j++) a.a[j]=ch[i]^48;
        for(int i=y,j=1; i>=x+1; i--,j++) b.a[j]=ch[i]^48;
        for(int i=n,j=1; i>=y+1; i--,j++) c.a[j]=ch[i]^48;
        if(a+b==c){
            for(int i=1; i<=x; i++) putchar(ch[i]);putchar('+');for(int i=x+1; i<=y; i++) putchar(ch[i]);putchar('=');for(int i=y+1; i<=n; i++) putchar(ch[i]);putchar('\n');
            return 0;
        }
    }
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

93944386991110939443869921

output:


result:

wrong answer 1st lines differ - expected: '939443869911+10=939443869921', found: ''

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

454431423351945476661

output:


result:

wrong answer 1st lines differ - expected: '45443142+33519=45476661', found: ''

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1236kb

input:

807674775734008076747757340

output:


result:

wrong answer 1st lines differ - expected: '8076747757340+0=8076747757340', found: ''

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

47936157175791479437362

output:


result:

wrong answer 1st lines differ - expected: '479361571+75791=479437362', found: ''

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

8684160719450790868416071945079

output:


result:

wrong answer 1st lines differ - expected: '868416071945079+0=868416071945079', found: ''

Test #6:

score: 0
Wrong Answer
time: 1ms
memory: 1240kb

input:

3150325920082064131504079841

output:


result:

wrong answer 1st lines differ - expected: '31503259200+820641=31504079841', found: ''

Test #7:

score: 0
Runtime Error

input:

9261598869160335057970310229283612818845075445997339978957735823966059362624832990688056822195031820...

output:


result:


Test #8:

score: 0
Runtime Error

input:

4701609646464966471786112512122938863110668626139644802941307402470417596440427343650542031038908331...

output:


result:


Test #9:

score: 0
Runtime Error

input:

9257202799561473086244723527541134302291247300137775651258683390946286052100443441136004200934466749...

output:


result:


Test #10:

score: 0
Runtime Error

input:

4416728326936622856150699213135191910979789931946758505266833530473668185681946524100519868737557117...

output:


result:


Test #11:

score: 0
Runtime Error

input:

3061041362133228009344583160193669358685821190644364754039063887060686947993153784177860432362852231...

output:


result:


Test #12:

score: 0
Runtime Error

input:

8531603642906385747583399978283975747482545589702570907905311483331351132043885935451850547243462360...

output:


result:


Test #13:

score: 0
Runtime Error

input:

3334731073815946487356418721839719459473953466541212185094515699104064312397044785650155583747481091...

output:


result:


Test #14:

score: 0
Runtime Error

input:

7113181137342253409543193679407457232222929505170124047879622285985297849800487899060254257891240998...

output:


result:


Test #15:

score: 0
Runtime Error

input:

2226576415518523623432262365703901892218433052474981493103118406267304359951441730045611163295598279...

output:


result:


Test #16:

score: 0
Runtime Error

input:

7282380568017210841065149843225478309106222219195648724985194189592224139941051182898879219925651713...

output:


result:


Test #17:

score: 0
Runtime Error

input:

6172023021615818261278406139291452768117320772111777913293782100858187571870407831738505138788606992...

output:


result:


Test #18:

score: 0
Runtime Error

input:

1641729471229192950020661455158841378773007409709289573050186474289570718374236969060246403530844480...

output:


result:


Test #19:

score: 0
Runtime Error

input:

6878197288916471551222877849454599200431985721720556540869310866854759368074574456390764568703818252...

output:


result:


Test #20:

score: 0
Runtime Error

input:

1336335135465815186373041570173603326293570642638147764739718555949768772153761126675803325646928488...

output:


result: