CSES - E4590 2018 2 - Results
Submission details
Task:ModAdd
Sender:dsedov
Submission time:2018-09-22 13:53:42 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.02 sdetails
#20.05 sdetails
#30.15 sdetails
#40.06 sdetails
#50.06 sdetails
#60.05 sdetails
#70.16 sdetails
#8ACCEPTED0.15 sdetails
#90.06 sdetails
#100.05 sdetails

Code

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932384626433832795

#define TASK "a"
//#define CONTEST "1"

string s1, s2;

void Load()
{
	cin >> s1 >> s2;
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
}

void Solve()
{
	int n1 = s1.length();
	int n2 = s2.length();
	int n = max(n1, n2);
	string s="";

	for(int i = 0; i < n; i++)
	{
		if(i < n1 && i < n2)
			s += to_string((int)(s1[i] - '0' + s2[i] - '0')%10);
		else if(i<n1)
			s += s1[i];
		else
			s += s2[i];
	}
	reverse(s.begin(), s.end());

	cout << stoi(s);
}

int main()
{
#ifdef CONTEST
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
	
	Load();
	Solve();

	return 0;
}

Test details

Test 1

Verdict:

input
3797629225
9766508989

correct output
2453127104

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 2

Verdict:

input
552139016901047883384892240490...

correct output
552139016901047883384892240490...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 3

Verdict:

input
860793811134668093345482099582...

correct output
487710306894083216377653715430...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 4

Verdict:

input
2
870841652294197226626825161089...

correct output
870841652294197226626825161089...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 5

Verdict:

input
0
404905566051213252279994991040...

correct output
404905566051213252279994991040...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 6

Verdict:

input
430112167406460960088878635088...

correct output
430112167406460960088878635088...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 7

Verdict:

input
867016005819001635643395991596...

correct output
999999999999999999999999999999...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 8

Verdict: ACCEPTED

input
120453771521975552204976752778...

correct output
0

user output
0

Test 9

Verdict:

input
239979749009277805816504910098...

correct output
239979749009277805816504910098...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

Test 10

Verdict:

input
990963963634143754324162574923...

correct output
818540385713473048971388312665...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi