Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)

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 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 "<" if a < b and the symbol ">" ifa > 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
>
 
   
   这题我也是傻了,一开始原本想用字符串做的,但一下子跳出一个高精度做法,忘了这个数太过大了。。。。
 
   
AC代码:
 
   
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
using namespace std;
#define CRL(a) memset(a,0,sizeof(a))
typedef  __int64 ll;
#define T 1000010
#define mod 1000000007

char s1[T],s2[T];

int main()
{
#ifdef zsc
    freopen("input.txt","r",stdin);
#endif

	int i,j,k,ls1,ls2;

	while(~scanf("%s%s",&s1,&s2))
	{
		int len1=strlen(s1),len2=strlen(s2);
		ls1 = ls2 = 0;
		while(s1[ls1]=='0')
		{
			ls1++;
		}
		while(s2[ls2]=='0')
		{
			ls2++;
		}
		for(i=ls1;i<=len1;++i){
			s1[i-ls1] = s1[i];
		}
		for(i=ls2;i<=len2;++i){
			s2[i-ls2] = s2[i];
		}
		if(len1-ls1>len2-ls2){
			printf(">\n");
		}
		else if(len1-ls1<len2-ls2){
			printf("<\n");
		}
		else {
			int c = strcmp(s1,s2);
			if(c>0){
				printf(">\n");
			}
			else if(c<0){
				printf("<\n");
			}
			else
			printf("=\n");
		}

	}
	

    return 0;
}


 
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值