Background of small x addition difficulties
In the first programming class, the teacher asked everyone to write a program to calculate the sum of two positive integers.
After seeing small X's disdainful eyes, the teacher decided to make small x more difficult. Take the sum of 12 and 3 as an example.
Add unnecessary spaces to the original formula and then give it to small X.
This is silly. I hope you can help him.
Description
Calculates the sum of the two given numbers.
Input Format
The first line contains a string, indicating the expression given by the instructor to Xiao X.
Output Format
8
If the result of a sub-statement cannot exceed 10, the first row contains an integer representing the result of the sub-statement; otherwise, the first row contains a string.
"Large ".
Sample Data 1
Input
12345 + 54321
Output
66666
Sample Data 2
Input
8 0 00 0 0 00 + 2 0 00 0 01
Output
Large
Remarks
8
For 30% of the data, the formula sub-contains no useless spaces, and the formula sub-results cannot exceed 10.
For 100% of data, the string length cannot exceed 100.
Ideas
High precision is not required for questions or brute force attacks.
Code
#include<iostream>#include<cstdlib>#include<cstdio>using namespace std;long long a,b;string s;int ak,bk,sk;int main(){ getline(cin,s); ak=0;bk=0; sk=0; while (s[sk]!=‘+‘) { if (s[sk]!=‘ ‘) {ak++;;a=a*10+int(s[sk])-int(‘0‘);} sk++; if (ak>12) { cout<<"Large"<<endl; return 0; } } sk++; while (sk<=s.length()-1) { if (s[sk]!=‘ ‘) {bk++;b=b*10+int(s[sk])-int(‘0‘);} sk++; if (bk>12) { cout<<"Large"<<endl; return 0; } } a+=b; if ((a-100000000)>0) cout<<"Large"<<endl; else cout<<a<<endl; return 0; }
Result
[Water] addition difficulties of codecomb small x