您的位置:首页 > 其它

CodeForces 616A Comparing Two Long Integers

2016-07-24 09:00 225 查看
题目:

Description

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 functioninput() 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 Input

Input
9
10


Output
<


Input
11
10


Output
>


Input
00012345
12345


Output
=


Input
0123
9


Output
>


Input
0123
111


Output
>


就是比较2个整数的大小,很简单。

主要就是c语言不熟悉。

代码:

#include<stdio.h>#include <stdlib.h>#include<string.h>int main()
{
char*s1 = new char[1000000];
char*s2 = new char[1000000];
int l1, l2;
char c;
while (gets(s1)&&gets(s2))
{
l1 = strlen(s1);
l2 = strlen(s2);
int i = 0, j = 0;
while (s1[i] == '0'&& l1)
{
i++;
l1--;
}
while (s2[j] == '0'&& l2)
{
j++;
l2--;
}
if (l1 > l2)c='>';
else if (l1 < l2)c='<';
else
{
while (s1[i])
{
if (s1[i]>s2[j])
{
c = '>';
break;
}
if (s1[i]<s2[j])
{
c = '<';
break;
}
i++;
j++;
l1--;
}
if (l1 == 0)c = '=';
}
printf("%c\n", c);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: