CSES - E4590 2016 2 - Results
Submission details
Task:ModAdd
Sender:Ollie
Submission time:2016-09-24 13:31:08 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.29 sdetails
#3ACCEPTED0.32 sdetails
#4ACCEPTED0.30 sdetails
#5ACCEPTED0.29 sdetails
#6ACCEPTED0.24 sdetails
#7ACCEPTED0.32 sdetails
#8ACCEPTED0.29 sdetails
#9ACCEPTED0.26 sdetails
#10ACCEPTED0.11 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(a.length() != l) {
                   ^
input/code.cpp:14:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<l-a.length();i++) padded_a += "0";
                            ^
input/code.cpp:17:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(b.length() != l) {
                   ^
input/code.cpp:18:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<l-b.length();i++) padded_b += "0";
                            ^

Code

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int l = max(a.length(), b.length());
	string padded_a="", padded_b="";
	if(a.length() != l) {
		for(int i=0;i<l-a.length();i++) padded_a += "0";
	}
	padded_a += a;
	if(b.length() != l) {
		for(int i=0;i<l-b.length();i++) padded_b += "0";
	}
	padded_b += b;
	string res = "";
	bool az=true;
	for(int i=0;i<l;i++) {
		int va = padded_a[i]-'0';
		int vb = padded_b[i]-'0';
		int r = (va+vb)%10;
		res += to_string(r);
		if(r!=0) az=false;
	}
	if(az) {
	cout<<0<<endl; return 0;
	}
	int s = 0;
	while(res[s] == '0' && s<l) s++;
	for(;s<l;s++) cout << res[s];
	cout << endl;
	return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
3797629225
9766508989

correct output
2453127104

user output
2453127104

Test 2

Verdict: ACCEPTED

input
552139016901047883384892240490...

correct output
552139016901047883384892240490...

user output
552139016901047883384892240490...

Test 3

Verdict: ACCEPTED

input
860793811134668093345482099582...

correct output
487710306894083216377653715430...

user output
487710306894083216377653715430...

Test 4

Verdict: ACCEPTED

input
2
870841652294197226626825161089...

correct output
870841652294197226626825161089...

user output
870841652294197226626825161089...

Test 5

Verdict: ACCEPTED

input
0
404905566051213252279994991040...

correct output
404905566051213252279994991040...

user output
404905566051213252279994991040...

Test 6

Verdict: ACCEPTED

input
430112167406460960088878635088...

correct output
430112167406460960088878635088...

user output
430112167406460960088878635088...

Test 7

Verdict: ACCEPTED

input
867016005819001635643395991596...

correct output
999999999999999999999999999999...

user output
999999999999999999999999999999...

Test 8

Verdict: ACCEPTED

input
120453771521975552204976752778...

correct output
0

user output
0

Test 9

Verdict: ACCEPTED

input
239979749009277805816504910098...

correct output
239979749009277805816504910098...

user output
239979749009277805816504910098...

Test 10

Verdict: ACCEPTED

input
990963963634143754324162574923...

correct output
818540385713473048971388312665...

user output
818540385713473048971388312665...