CodeForces - 616A Comparing Two Long Integers (模拟)比较两个数大小
来源:互联网 发布:ps dr3插件for mac 编辑:程序博客网 时间:2024/06/01 21:42
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 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 Input
910
<
1110
>
0001234512345
=
01239
>
0123111
>
Source
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<map>#include<stack>#include<queue>#include<math.h>#define INF 0x3f3f3f3f#define ull unsigned long long#define ll long long#define IN __int64#define N 1000010#define M 1000000007using namespace std;char a[N],b[N];char x[N],y[N];int main(){int t,n,m,i,j,k;while(scanf("%s%s",a,b)!=EOF){int aa=0,bb=0,la,lb,ka,kb;la=strlen(a);lb=strlen(b);bool fa=false,fb=false;if(strcmp(a,b)==0){printf("=\n");continue;}for(i=0;i<la;i++){if(a[i]=='0'){aa=i;fa=true;continue;}elsebreak;}for(i=0;i<lb;i++){if(b[i]=='0'){bb=i;fb=true;continue;}elsebreak;}if(fa) aa++;if(fb) bb++;ka=0;kb=0;for(i=aa;i<la;i++)x[ka++]=a[i];for(i=bb;i<lb;i++)y[kb++]=b[i];if(ka>kb)printf(">\n");else if(ka<kb)printf("<\n");else{if(strcmp(x,y)>0)printf(">\n");else if(strcmp(x,y)==0)printf("=\n");elseprintf("<\n");}memset(a,'\0',sizeof(a));memset(b,'\0',sizeof(b));memset(x,'\0',sizeof(x));memset(y,'\0',sizeof(y));}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 616A Comparing Two Long Integers
- CodeForces 616 A. Comparing Two Long Integers(水~)
- Codeforces--616A--Comparing Two Long Integers(模拟水题)
- Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
- CodeForces 616A Comparing Two Long Integers【字符串】
- day4 CodeForces 616A Comparing Two Long Integers
- CodeForce 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
- Educational Codeforces Round 5 A. Comparing Two Long Integers (水)
- Comparing Two Long Integers
- LeetCode | Divide Two Integers(两个数相除)
- Hibernate Validator
- 静态链表
- My enum is not a class or namespace
- Java并发编程系列之二十一:CountdownLatch
- 获取设备上的调试信息与崩溃日志分析
- CodeForces - 616A Comparing Two Long Integers (模拟)比较两个数大小
- 数组转集合,集合转数组
- AB是一家?VAO与VBO
- C#目录文件监控
- lucene的丰富的各种查询(二)
- 设计模式之适配器模式
- OpenCV中CommandLineParser类
- 高通平台环境搭建,编译,系统引导流程分析
- C# out、ref关键字的用法和区别