码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces 616A Comparing Two Long Integers

时间:2016-01-12 16:57:02      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:

A. Comparing Two Long Integers

 

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().

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.

Output

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

Sample test(s)
input
9
10
output
<
input
11
10
output
>
input
00012345
12345
output
=
input
0123
9
output
>
input
0123
111
output
>
#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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!