Codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers 高精度比大小,模拟
A. Comparing Two Long Integers
题目连接:
http://www.codeforces.com/contest/616/problem/A
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/printf instead 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
9
10
Sample Output
<
Hint
题意
给你两个带前导0的高精度数字,然后让你比大小。
题解:
模拟一下就好了,首先看数位,然后再看每一位的数字就行了
代码
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
cin>>a>>b;
int len1 = a.size(),len2 = b.size();
int la = 0,lb = 0;
while(a[la]=='0'&&la<len1)la++;
while(b[lb]=='0'&&lb<len2)lb++;
if(len1-la>len2-lb)return puts(">");
if(len1-la<len2-lb)return puts("<");
for(int i=la;i<len1;i++)
{
if(a[i]>b[i-la+lb])return puts(">");
if(a[i]<b[i-la+lb])return puts("<");
}
return puts("=");
}
Codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers 高精度比大小,模拟的更多相关文章
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers
题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...
- Educational Codeforces Round 5 A. Comparing Two Long Integers
A. Comparing Two Long Integers time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- codeforces Educational Codeforces Round 16-E(DP)
题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...
- Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph
E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...
- Codeforces Educational Codeforces Round 15 D. Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Educational Codeforces Round 15 C. Cellular Network
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学
E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...
随机推荐
- 360网站卫士推出google字体加速方案
最近,有网友反映称谷歌官网域名google.com.谷歌香港google.com.hk都打不开, ping了一下google.com和google.com.hk两个域名的服务器情况,最后ping出来的 ...
- Nginx中的upstream轮询机制介绍
Nginx中upstream有以下几种方式: 1.轮询(weight=1) 默认选项,当weight不指定时,各服务器weight相同, 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器d ...
- C++中,申请字符串数组可用new实现
C++中,申请字符串数组可用new实现: char ** list = new char*[MAX_NUM]; for (int i = 0; i< MAX_LOOP; i++) list[i] ...
- SQL跨数据库复制表数据
SQL跨数据库复制表数据 不同服务器数据库之间的数据操作 不同数据库之间复制表的数据的方法: 当表目标表存在时: insert into 目的数据库..表 select * from 源数据库.. ...
- Win10正式版激活方法有哪些?如何激活Win10?
很多用户都想将系统升级到Win10,但是却不知道怎么激活Win10正式版的方法,其实不同版本激活正式版Win10的方法秘钥不同,下面99安卓网小编就分享一些激活Win10正式版的方法和秘钥,供大家参考 ...
- 在Mac OS X 10.9上安装 Thrift 0.9.1
Thrift 0.9.1 官方文档中对于Mac OS X上的安装描述适合 10.8,但不适用于10.9. Homebrew macport 默认都不能在 10.9上安装Thrift 0.9.1成功 ...
- http协议要点
概念: HTTP是Hyper Text Transfer Protocol(超文本传输协议)的缩写.它的发展是万维网协会(World Wide Web Consortium)和Internet工作小组 ...
- windows程序移植linux
1,路径名统一用正斜杠“/”.(windows下正反斜杠都识别,linux只认正斜杠.) 2,统一使用UTF-8格式编码. vim中无法保存汉字时,可输入下列命令: :set fileencoding ...
- 验证dictionary重复键
if (dict.ContainsKey("sadsa")) { }
- postsharp初体验
首先,有必要先介绍下,什么叫做AOP(Aspect-Oriented Programming,面向切面编程).下图是百度的词条解释 用图来解释可能更直接了当些: ps:图片来自http://www.c ...