CodeForces 616A Comparing Two Long Integers
来源:互联网 发布:中国科技实力 知乎 编辑:程序博客网 时间:2024/06/06 20:25
题目:
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 functioninput() 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
>
就是比较2个整数的大小,很简单。
主要就是c语言不熟悉。
代码:
#include<stdio.h>#include <stdlib.h> #include<string.h>int main(){char*s1 = new char[1000000];char*s2 = new char[1000000];int l1, l2;char c;while (gets(s1)&&gets(s2)){l1 = strlen(s1);l2 = strlen(s2);int i = 0, j = 0;while (s1[i] == '0'&& l1){i++;l1--;}while (s2[j] == '0'&& l2){j++;l2--;}if (l1 > l2)c='>';else if (l1 < l2)c='<';else{while (s1[i]){if (s1[i]>s2[j]){c = '>';break;}if (s1[i]<s2[j]){c = '<';break;}i++;j++;l1--;}if (l1 == 0)c = '=';}printf("%c\n", c);}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
- c++
- MySQL的deocode,与not in的关联查询实现
- UEFI+GPT+KDE5+archlinux安装教程(自用)
- poj 3468 线段树区间更新
- hdu2579 Dating with girls(2)--BFS
- CodeForces 616A Comparing Two Long Integers
- OpenCV+Visual Studio 2010、2012、2013、2015
- java基础学习(7)浅析final,private,public,protected,static等关键以及它们的区别的联系
- C++中的句柄
- [HDU 5729] Rigid Frameworks (二分图联通方案计数)
- maven启动 cannot be cast to javax.servlet.Filter/cannot be cast to javax.servlet.Servlet 报错
- java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
- 极角排序合集
- 简单dp算法——百炼05:切割回文