标签:
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<cstdio> #include<cstring> #include<stack> #include<iterator> #include<vector> #include<iostream> #include<map> #include<string> #include<algorithm> using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn=1e6+5; int main() { int len[2]; char s[2][maxn]; for(int i=0;i<2;i++) scanf("%s",s[i]),len[i]=strlen(s[i]); int i,j; for(i=0;i<len[0];i++) if(s[0][i]!=‘0‘)break; for(j=0;j<len[1];j++) if(s[1][j]!=‘0‘)break; if(len[0]-i>len[1]-j) puts(">"); else if(len[0]-i<len[1]-j) puts("<"); else { for(;i<len[0];i++,j++) if(s[0][i]!=s[1][j])break; i==len[0]?puts("="):puts(s[0][i]>s[1][j]?">":"<"); } return 0; }
codeforces 616A Comparing Two Long Integers
标签:
原文地址:http://www.cnblogs.com/homura/p/5124832.html