Educational Codeforces Round 5(A) 模拟

来源:互联网 发布:重庆大学网络自服务 编辑:程序博客网 时间:2024/05/02 22:32

A. Comparing Two Long Integers
time limit per test
1 second
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 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
910
output
<
input
1110
output
>
input
0001234512345
output
=
input
01239
output
>
input
0123111
output
>


题意:比较数字大小


题解:考虑数字很大,使用字符串模拟就可以了



#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>#include<set>using namespace std;#define LL long long #define inf 0x3f3f3f3f#define N 100000#define lson L,mid,rt<<1#define rson mid+1,R,rt<<1|1string s1,s2,ts1,ts2;int main(){#ifdef CDZSCfreopen("i.txt","r",stdin);#endifwhile(cin>>s1>>s2){ts1.clear();ts2.clear();int f=1;for(int i=0;i<s1.size();i++){if(s1[i]!='0'&&f){f=0;}if(!f){ts1+=s1[i];}}f=1;for(int i=0;i<s2.size();i++){if(s2[i]!='0'&&f){f=0;}if(!f){ts2+=s2[i];}}if(ts1.size()==ts2.size()){if(ts1==ts2)puts("=");else{puts(ts1<ts2?"<":">");}}else if(ts1.size()>ts2.size()){puts(">");}else puts("<");}return 0; }





0 0
原创粉丝点击