Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
来源:互联网 发布:网络新词及解释 编辑:程序博客网 时间:2024/05/17 17:44
You are given two very long integers a, b (leading zeroes are allowed). You should check what numbera orb 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 ofcin/cout in C++, prefer to use BufferedReader/PrintWriter instead ofScanner/System.out inJava. Don't use the function input() inPython2 instead of it use the functionraw_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.
Print the symbol "<" if a < b and the symbol ">" ifa > b. If the numbers are equal print the symbol "=".
910
<
1110
>
0001234512345
=
01239
>
0123111
>
这题我也是傻了,一开始原本想用字符串做的,但一下子跳出一个高精度做法,忘了这个数太过大了。。。。
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 1000000007char s1[T],s2[T];int main(){#ifdef zsc freopen("input.txt","r",stdin);#endifint 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");}elseprintf("=\n");}} return 0;}
- Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
- Educational Codeforces Round 5 A. Comparing Two Long Integers
- Educational Codeforces Round 5 A. Comparing Two Long Integers (水)
- CodeForces 616A Comparing Two Long Integers
- CodeForces 616A Comparing Two Long Integers
- CodeForces 616A Comparing Two Long Integers
- CodeForces 616A Comparing Two Long Integers
- Codeforces--616A--Comparing Two Long Integers(模拟水题)
- CodeForces - 616A Comparing Two Long Integers (模拟)比较两个数大小
- CodeForces 616 A. Comparing Two Long Integers(水~)
- A. Comparing Two Long Integers
- CodeForces 616A Comparing Two Long Integers【字符串】
- day4 CodeForces 616A Comparing Two Long Integers
- CF Comparing Two Long Integers 616A
- cf 616A Comparing Two Long Integers
- Comparing Two Long Integers
- CodeForce 616A Comparing Two Long Integers 字符串比较
- Educational Codeforces Round 5(A) 模拟
- 重学C++ (四) 语句
- ArcSDE空间数据库中SDE用户使用探讨
- ReactNative之开发Mac环境配置
- c#控件说明
- 枚举类
- Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
- 使用系统自带CheckBox实现单选效果的2个线性布局切换
- Swift 懒加载
- 上下拉电阻的设计
- Ajax等待返回结果时,弹出一个友好的等待提示
- extjs 架构图
- Android studio 项目没有错误,运行按钮为灰色无法运行,rebuild 和 clean 都没有用
- 代码控制IE11以兼容IE8的模式启动
- Java JSON技术框架选型与实例