CodeForces 616A Comparing Two Long Integers
来源:互联网 发布:阿里云ssh登录 编辑:程序博客网 时间:2024/06/07 18:27
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().
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.
Print the symbol "<" if a < b and the symbol ">" if a > b. If the numbers are equal print the symbol "=".
910
<
1110
>
0001234512345
=
01239
>
0123111
>
去掉前导0,然后比较长度,长度相等再一位一位比较
#include <iostream>#include<cstdio>#include<cstring>#define maxn 10000010using namespace std;char a[maxn],b[maxn];int main(){ while(~scanf("%s%s",a,b)) { int lena=strlen(a); int lenb=strlen(b); int i=0,j=0; while(i<lena&&a[i]=='0') i++; while(j<lenb&&b[j]=='0') j++; if(lena-i>lenb-j) { printf(">\n"); continue; } else if(lena-i<lenb-j) { printf("<\n"); continue; } while(i<lena&&j<lenb) { if(a[i]>b[j]) { printf(">\n"); break; } else if(a[i]<b[j]) { printf("<\n"); break; } else i++,j++; } if(i==lena&&j==lenb) printf("=\n"); }; return 0;}
- 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(水~)
- 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
- 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 (模拟)比较两个数大小
- CodeForce 616A Comparing Two Long Integers 字符串比较
- Comparing Two Long Integers
- Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
- Educational Codeforces Round 5 A. Comparing Two Long Integers (水)
- Codeforces 872 A Search for Pretty Integers
- 研一寒假Docker学习笔记1
- HDU 1201:18岁生日【水】
- 网络编程归纳总结五阶段
- 数据结构之大O、大Ω和大Θ
- 动态代理例子
- CodeForces 616A Comparing Two Long Integers
- JavaScript 数字与字符串 比较大小
- swift入门———函数
- 浅析数据结构中栈与C实现
- C++开发人脸性别识别教程(10)——添加图片的人脸检测程序
- Java类集框架
- Java执行顺序
- 名侦探柯南(贪心问题)
- CodeForces 616B Dinner with Emma