#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll converter(string s)
{
ll l = s.size(), f = 0, i;
for(i=0;i<l;i++)
{
f = f*10 + (s[i] - 48);
if(f > 2147483647)
{
f = -1;
break;
}
}
return f;
}
int main()
{
string a, b;
char s;
while(cin >> a >> s >> b)
{
cout << a << " " << s << " " << b << endl;
ll p = converter(a);
if(p == -1)
cout << "first number too big" << endl;
ll c = converter(b);
if(c == -1)
cout << "second number too big" << endl;
if(p == -1 || c == -1)
{
if(p == 0 || c == 0)
continue;
cout << "result too big" << endl;
continue;
}
if(s == '+')
{
ll d = p+c;
if(d > 2147483647 || d < -2147483648)
cout << "result too big" << endl;
continue;
}
if(s == '*')
{
ll d = p*c;
if(d > 2147483647 || d < -2147483648)
cout << "result too big" << endl;
continue;
}
}
return 0;
}
#define ll long long int
using namespace std;
ll converter(string s)
{
ll l = s.size(), f = 0, i;
for(i=0;i<l;i++)
{
f = f*10 + (s[i] - 48);
if(f > 2147483647)
{
f = -1;
break;
}
}
return f;
}
int main()
{
string a, b;
char s;
while(cin >> a >> s >> b)
{
cout << a << " " << s << " " << b << endl;
ll p = converter(a);
if(p == -1)
cout << "first number too big" << endl;
ll c = converter(b);
if(c == -1)
cout << "second number too big" << endl;
if(p == -1 || c == -1)
{
if(p == 0 || c == 0)
continue;
cout << "result too big" << endl;
continue;
}
if(s == '+')
{
ll d = p+c;
if(d > 2147483647 || d < -2147483648)
cout << "result too big" << endl;
continue;
}
if(s == '*')
{
ll d = p*c;
if(d > 2147483647 || d < -2147483648)
cout << "result too big" << endl;
continue;
}
}
return 0;
}
Comments
Post a Comment