UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#192838#2656. addtkswls1002091ms36860kbC++112.0kb2023-10-12 11:31:102023-10-12 12:02:18

answer

#include <bits/stdc++.h>
using namespace std;
string s;
int n, cnta, cntc, a[1000006];
long long mod = 998244353, mmod = 1000000007, s1[1000006], s2[1000006], x[1000006], xx[1000006];
long long ksm(long long p, long long q, long long m) {
	if (q == 0) return 1;
	if (q == 1) return p;
	if (q & 1) return ksm(p * p % m, q / 2, m) * p % m;
	return ksm(p * p % m, q / 2, m);
}
inline long long ge(int l, int r) {
	return ((s1[l] - s1[r + 1] + mod) % mod) * x[n - r] % mod;
}
inline long long gget(int l, int r) {
	return ((s2[l] - s2[r + 1] + mmod) % mmod) * xx[n - r] % mmod;
}
inline bool check( ) {
	return ((ge(1, cnta) + ge(cnta + 1, cntc - 1)) % mod == ge(cntc, n)) && ((gget(1, cnta) + gget(cnta + 1, cntc - 1)) % mmod == gget(cntc, n));
	return true;
}
inline void print() {
	for (int i = 1; i <= cnta; i++) {
		cout << a[i];
	}
	cout << "+";
	for (int i = cnta + 1; i < cntc; i++) {
		cout << a[i];
	}
	cout << "=";
	for (int i = cntc; i <= n; i++) {
		cout << a[i];
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	n = s.size();
	s = ' ' + s;
	long long b1 = 1, b2 = 1;
	for (int i = n; i >= 1; i--) {
		a[i] = s[i] - '0';
		s1[i] = (s1[i + 1] + a[i] * b1 % mod) % mod;
		s2[i] = (s2[i + 1] + a[i] * b2 % mmod) % mmod;
//		cout << s2[i] << " ";
		b1 = b1 * 10;
		b1 %= mod;
		b2 *= 10;
		b2 %= mmod;
	}
//	cout << endl;
	x[0] = xx[0] = 1;
	x[1] = ksm(10, mod - 2, mod);
	xx[1] = ksm(10, mmod - 2, mmod);
//	cout << xx[1] << endl;
	for (int i = 2; i <= n; i++) {
		x[i] = x[i - 1] * x[1] % mod;
		xx[i] = xx[i - 1] * xx[1] % mmod;
	}
	for (int i = 1; i <= n; i++) {
		cnta = i;
		if (n - i - i <= i && n - i - i >= 1) {
			cntc = n - i + 1;
			if (check()) {
				print();
				return 0;
			}
		}
		if (n - i - (i + 1) <= i && n - i - (i + 1) >= 1) {
			cntc = n - (i + 1) + 1;
			if (check()) {
				print();
				return 0;
			}
		}
		if ((n - i) / 2 >= 1) {
			cntc = n - (n - i + 1) / 2 + 1;
			if (check()) {
				print();
				return 0;
			}
		}
	}
}

Details

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

Test #1:

score: 5
Accepted
time: 0ms
memory: 1268kb

input:

93944386991110939443869921

output:

939443869911+10=939443869921

result:

ok single line: '939443869911+10=939443869921'

Test #2:

score: 5
Accepted
time: 1ms
memory: 1268kb

input:

454431423351945476661

output:

45443142+33519=45476661

result:

ok single line: '45443142+33519=45476661'

Test #3:

score: 5
Accepted
time: 0ms
memory: 1268kb

input:

807674775734008076747757340

output:

8076747757340+0=8076747757340

result:

ok single line: '8076747757340+0=8076747757340'

Test #4:

score: 5
Accepted
time: 0ms
memory: 1268kb

input:

47936157175791479437362

output:

479361571+75791=479437362

result:

ok single line: '479361571+75791=479437362'

Test #5:

score: 5
Accepted
time: 0ms
memory: 1268kb

input:

8684160719450790868416071945079

output:

868416071945079+0=868416071945079

result:

ok single line: '868416071945079+0=868416071945079'

Test #6:

score: 5
Accepted
time: 0ms
memory: 1272kb

input:

3150325920082064131504079841

output:

31503259200+820641=31504079841

result:

ok single line: '31503259200+820641=31504079841'

Test #7:

score: 5
Accepted
time: 134ms
memory: 30884kb

input:

9261598869160335057970310229283612818845075445997339978957735823966059362624832990688056822195031820...

output:

9261598869160335057970310229283612818845075445997339978957735823966059362624832990688056822195031820...

result:

ok single line: '926159886916033505797031022928...3054231497478113058482456217163'

Test #8:

score: 5
Accepted
time: 147ms
memory: 31432kb

input:

4701609646464966471786112512122938863110668626139644802941307402470417596440427343650542031038908331...

output:

4701609646464966471786112512122938863110668626139644802941307402470417596440427343650542031038908331...

result:

ok single line: '470160964646496647178611251212...8748395060129898210762369495747'

Test #9:

score: 5
Accepted
time: 158ms
memory: 36856kb

input:

9257202799561473086244723527541134302291247300137775651258683390946286052100443441136004200934466749...

output:

9257202799561473086244723527541134302291247300137775651258683390946286052100443441136004200934466749...

result:

ok single line: '925720279956147308624472352754...2243909924739032590362234901192'

Test #10:

score: 5
Accepted
time: 166ms
memory: 33876kb

input:

4416728326936622856150699213135191910979789931946758505266833530473668185681946524100519868737557117...

output:

4416728326936622856150699213135191910979789931946758505266833530473668185681946524100519868737557117...

result:

ok single line: '441672832693662285615069921313...3111611421682233543698480114264'

Test #11:

score: 5
Accepted
time: 176ms
memory: 36048kb

input:

3061041362133228009344583160193669358685821190644364754039063887060686947993153784177860432362852231...

output:

3061041362133228009344583160193669358685821190644364754039063887060686947993153784177860432362852231...

result:

ok single line: '306104136213322800934458316019...4042293112332153562949434601781'

Test #12:

score: 5
Accepted
time: 171ms
memory: 36316kb

input:

8531603642906385747583399978283975747482545589702570907905311483331351132043885935451850547243462360...

output:

8531603642906385747583399978283975747482545589702570907905311483331351132043885935451850547243462360...

result:

ok single line: '853160364290638574758339997828...5180929300855954383525415798317'

Test #13:

score: 5
Accepted
time: 168ms
memory: 36588kb

input:

3334731073815946487356418721839719459473953466541212185094515699104064312397044785650155583747481091...

output:

3334731073815946487356418721839719459473953466541212185094515699104064312397044785650155583747481091...

result:

ok single line: '333473107381594648735641872183...2104466046161989376727619609117'

Test #14:

score: 5
Accepted
time: 181ms
memory: 35232kb

input:

7113181137342253409543193679407457232222929505170124047879622285985297849800487899060254257891240998...

output:

7113181137342253409543193679407457232222929505170124047879622285985297849800487899060254257891240998...

result:

ok single line: '711318113734225340954319367940...7499580501189814539270742795615'

Test #15:

score: 5
Accepted
time: 174ms
memory: 36048kb

input:

2226576415518523623432262365703901892218433052474981493103118406267304359951441730045611163295598279...

output:

2226576415518523623432262365703901892218433052474981493103118406267304359951441730045611163295598279...

result:

ok single line: '222657641551852362343226236570...1283546754745341452795514550351'

Test #16:

score: 5
Accepted
time: 162ms
memory: 35768kb

input:

7282380568017210841065149843225478309106222219195648724985194189592224139941051182898879219925651713...

output:

7282380568017210841065149843225478309106222219195648724985194189592224139941051182898879219925651713...

result:

ok single line: '728238056801721084106514984322...6665028468440209585025731431738'

Test #17:

score: 5
Accepted
time: 195ms
memory: 36860kb

input:

6172023021615818261278406139291452768117320772111777913293782100858187571870407831738505138788606992...

output:

6172023021615818261278406139291452768117320772111777913293782100858187571870407831738505138788606992...

result:

ok single line: '617202302161581826127840613929...9022854228506784321805225740782'

Test #18:

score: 5
Accepted
time: 96ms
memory: 22752kb

input:

1641729471229192950020661455158841378773007409709289573050186474289570718374236969060246403530844480...

output:

1641729471229192950020661455158841378773007409709289573050186474289570718374236969060246403530844480...

result:

ok single line: '164172947122919295002066145515...1428289195899821981683641721297'

Test #19:

score: 5
Accepted
time: 78ms
memory: 16508kb

input:

6878197288916471551222877849454599200431985721720556540869310866854759368074574456390764568703818252...

output:

6878197288916471551222877849454599200431985721720556540869310866854759368074574456390764568703818252...

result:

ok single line: '687819728891647155122287784945...4028111836067678989020741708082'

Test #20:

score: 5
Accepted
time: 84ms
memory: 19220kb

input:

1336335135465815186373041570173603326293570642638147764739718555949768772153761126675803325646928488...

output:

1336335135465815186373041570173603326293570642638147764739718555949768772153761126675803325646928488...

result:

ok single line: '133633513546581518637304157017...5916651705852916207264857823016'