2 seconds
256 megabytes
standard input
standard output
You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printfinstead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java. Don't use the function input() in Python2 instead of it use the function raw_input().
The first line contains a non-negative integer a.
The second line contains a non-negative integer b.
The numbers a, b may contain leading zeroes. Each of them contains no more than 106 digits.
Print the symbol "<" if a < b and the symbol ">" if a > b. If the numbers are equal print the symbol "=".
9
10
<
11
10
>
00012345
12345
=
0123
9
>
0123
111
>
字符串,去掉前面的零,比较大小,水题。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld; int main()
{
char a[];
char b[];
cin >> a;
cin >> b;
int lena,lenb;
int i,j;
for(i = ; a[i] == ''; i++);
for(j = ; b[j] == ''; j++);
lena = strlen(a)-i;
lenb = strlen(b)-j;
if(lena == && lenb == )
{
cout << '=';
return ;
}
else if(lena > lenb)
cout << '>';
else if(lena < lenb)
cout << '<';
else
{
int count = ;
int k = strlen(a);
for(int m = i, n = j;m < k; m++, n++)
{
int p = a[m] - '';
int q = b[n] - '';
if(p == q)
{
count = ;
continue;
}
else if(p > q)
{
count = ;
cout << '>';
break;
}
else
{
count = ;
cout << '<';
break;
}
}
if(count)
{
cout << '=';
}
} return ;
}