UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215120#2656. addThySecret100453ms17644kbC++112.1kb2024-11-26 19:35:222024-11-26 23:02:08

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1000010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 9, base = 10;

template<typename Type>
inline void read(Type &res)
{
    res = 0;
    int ch = getchar(), flag = 0;
    while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }

char str[N];
int n, hsh[N], fc[N];

inline int gethash(int l, int r) { return (hsh[r] - hsh[l - 1] * fc[r - l + 1] % mod + mod) % mod; }

void print(int L, int R)
{
    for (int i = 1; i <= n; i ++)
    {
        if (i == L) putchar('+');
        else if (i == R) putchar('=');
        putchar(str[i]);
    }
    putchar(10);
}

inline bool zero(int L, int R) { return str[L] == '0' && L > R; }

bool check(int L, int R)
{
    // DEBUG(L, R);
    if (L <= 1 || zero(1, L - 1) || zero(L, R - 1) || zero(R, n)) return false;
    else if ((gethash(1, L - 1) + gethash(L, R - 1)) % mod == gethash(R, n) % mod)
        return print(L, R), true;
    return false;
}

signed main()
{
    for (int i = fc[0] = 1; i < N; i ++) fc[i] = fc[i - 1] * base % mod;
    scanf("%s", str + 1), n = strlen(str + 1);
    for (int i = 1; i <= n; i ++) hsh[i] = (hsh[i - 1] * base + str[i] - '0') % mod;

    bool flag = false;
    for (int i = n / 3; i <= n / 2; i ++)
        if (check(i, n - i + 1) || check(i + 1, n - i + 1) || check(n - i * 2 + 2, n - i + 1) || check(n - i * 2 + 1, n - i + 1))
            return 0;
    
    return 0;
}

详细

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

Test #1:

score: 5
Accepted
time: 9ms
memory: 8968kb

input:

93944386991110939443869921

output:

939443869911+10=939443869921

result:

ok single line: '939443869911+10=939443869921'

Test #2:

score: 5
Accepted
time: 9ms
memory: 8972kb

input:

454431423351945476661

output:

45443142+33519=45476661

result:

ok single line: '45443142+33519=45476661'

Test #3:

score: 5
Accepted
time: 9ms
memory: 8972kb

input:

807674775734008076747757340

output:

8076747757340+0=8076747757340

result:

ok single line: '8076747757340+0=8076747757340'

Test #4:

score: 5
Accepted
time: 9ms
memory: 8972kb

input:

47936157175791479437362

output:

479361571+75791=479437362

result:

ok single line: '479361571+75791=479437362'

Test #5:

score: 5
Accepted
time: 6ms
memory: 8968kb

input:

8684160719450790868416071945079

output:

868416071945079+0=868416071945079

result:

ok single line: '868416071945079+0=868416071945079'

Test #6:

score: 5
Accepted
time: 3ms
memory: 8972kb

input:

3150325920082064131504079841

output:

31503259200+820641=31504079841

result:

ok single line: '31503259200+820641=31504079841'

Test #7:

score: 5
Accepted
time: 27ms
memory: 16148kb

input:

9261598869160335057970310229283612818845075445997339978957735823966059362624832990688056822195031820...

output:

9261598869160335057970310229283612818845075445997339978957735823966059362624832990688056822195031820...

result:

ok single line: '926159886916033505797031022928...3054231497478113058482456217163'

Test #8:

score: 5
Accepted
time: 29ms
memory: 16336kb

input:

4701609646464966471786112512122938863110668626139644802941307402470417596440427343650542031038908331...

output:

4701609646464966471786112512122938863110668626139644802941307402470417596440427343650542031038908331...

result:

ok single line: '470160964646496647178611251212...8748395060129898210762369495747'

Test #9:

score: 5
Accepted
time: 35ms
memory: 17612kb

input:

9257202799561473086244723527541134302291247300137775651258683390946286052100443441136004200934466749...

output:

9257202799561473086244723527541134302291247300137775651258683390946286052100443441136004200934466749...

result:

ok single line: '925720279956147308624472352754...2243909924739032590362234901192'

Test #10:

score: 5
Accepted
time: 19ms
memory: 16920kb

input:

4416728326936622856150699213135191910979789931946758505266833530473668185681946524100519868737557117...

output:

4416728326936622856150699213135191910979789931946758505266833530473668185681946524100519868737557117...

result:

ok single line: '441672832693662285615069921313...3111611421682233543698480114264'

Test #11:

score: 5
Accepted
time: 38ms
memory: 17460kb

input:

3061041362133228009344583160193669358685821190644364754039063887060686947993153784177860432362852231...

output:

3061041362133228009344583160193669358685821190644364754039063887060686947993153784177860432362852231...

result:

ok single line: '306104136213322800934458316019...4042293112332153562949434601781'

Test #12:

score: 5
Accepted
time: 33ms
memory: 17472kb

input:

8531603642906385747583399978283975747482545589702570907905311483331351132043885935451850547243462360...

output:

8531603642906385747583399978283975747482545589702570907905311483331351132043885935451850547243462360...

result:

ok single line: '853160364290638574758339997828...5180929300855954383525415798317'

Test #13:

score: 5
Accepted
time: 36ms
memory: 17536kb

input:

3334731073815946487356418721839719459473953466541212185094515699104064312397044785650155583747481091...

output:

3334731073815946487356418721839719459473953466541212185094515699104064312397044785650155583747481091...

result:

ok single line: '333473107381594648735641872183...2104466046161989376727619609117'

Test #14:

score: 5
Accepted
time: 34ms
memory: 17212kb

input:

7113181137342253409543193679407457232222929505170124047879622285985297849800487899060254257891240998...

output:

7113181137342253409543193679407457232222929505170124047879622285985297849800487899060254257891240998...

result:

ok single line: '711318113734225340954319367940...7499580501189814539270742795615'

Test #15:

score: 5
Accepted
time: 28ms
memory: 17440kb

input:

2226576415518523623432262365703901892218433052474981493103118406267304359951441730045611163295598279...

output:

2226576415518523623432262365703901892218433052474981493103118406267304359951441730045611163295598279...

result:

ok single line: '222657641551852362343226236570...1283546754745341452795514550351'

Test #16:

score: 5
Accepted
time: 28ms
memory: 17352kb

input:

7282380568017210841065149843225478309106222219195648724985194189592224139941051182898879219925651713...

output:

7282380568017210841065149843225478309106222219195648724985194189592224139941051182898879219925651713...

result:

ok single line: '728238056801721084106514984322...6665028468440209585025731431738'

Test #17:

score: 5
Accepted
time: 45ms
memory: 17644kb

input:

6172023021615818261278406139291452768117320772111777913293782100858187571870407831738505138788606992...

output:

6172023021615818261278406139291452768117320772111777913293782100858187571870407831738505138788606992...

result:

ok single line: '617202302161581826127840613929...9022854228506784321805225740782'

Test #18:

score: 5
Accepted
time: 23ms
memory: 14224kb

input:

1641729471229192950020661455158841378773007409709289573050186474289570718374236969060246403530844480...

output:

1641729471229192950020661455158841378773007409709289573050186474289570718374236969060246403530844480...

result:

ok single line: '164172947122919295002066145515...1428289195899821981683641721297'

Test #19:

score: 5
Accepted
time: 16ms
memory: 12648kb

input:

6878197288916471551222877849454599200431985721720556540869310866854759368074574456390764568703818252...

output:

6878197288916471551222877849454599200431985721720556540869310866854759368074574456390764568703818252...

result:

ok single line: '687819728891647155122287784945...4028111836067678989020741708082'

Test #20:

score: 5
Accepted
time: 17ms
memory: 13340kb

input:

1336335135465815186373041570173603326293570642638147764739718555949768772153761126675803325646928488...

output:

1336335135465815186373041570173603326293570642638147764739718555949768772153761126675803325646928488...

result:

ok single line: '133633513546581518637304157017...5916651705852916207264857823016'