CodeForces 616A

来源:互联网 发布:linux 替换jar包文件 编辑:程序博客网 时间:2024/06/09 17:18
A. Comparing Two Long Integers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two very long integers a, b (leading zeroes are allowed). You should check what numbera 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 usescanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead ofScanner/System.out in Java. Don't use the function input() inPython2 instead of it use the function raw_input().

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 than106 digits.

Output

Print the symbol "<" ifa < b and the symbol ">" ifa > b. If the numbers are equal print the symbol "=".

Examples
Input
910
Output
<
Input
1110
Output
>
Input
0001234512345
Output
=
Input
01239
Output
>
Input
0123111
Output
>
模拟题,比较有前导0的两数的大小。
思路:跳过前导0,先比较长度,长度相等再一位一位的比较。
#include<iostream>#include<cstdio>#include<string>using namespace std;string s1,s2;char ss[1000005];int main(){    while(scanf("%s",&ss)!=EOF)    {         s1=ss;         scanf("%s",&ss);         s2=ss;         int len1=s1.length(),len2=s2.length();         int p1=0,p2=0;         while(s1[p1]=='0'&&p1<len1) p1++;         while(s2[p2]=='0'&&p2<len2) p2++;         if(len1-p1>len2-p2) {printf(">\n");continue;}         else if(len1-p1<len2-p2) {printf("<\n");continue;}         int i;         bool flag=false;         for(i=p1;i<len1;i++)        {            if(s1[i]>s2[i-p1+p2]) {printf(">\n");flag=true;break;}            if(s1[i]<s2[i-p1+p2]) {printf("<\n");flag=true;break;}        }        if(!flag) printf("=\n");    }    return 0;}


0 0
原创粉丝点击