Codeforces Round #333 (Div. 2) A. Two Bases 水题
A. Two Bases
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/602/problem/A
Description
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.
You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
Input
The first line of the input contains two space-separated integers n and bx (1 ≤ n ≤ 10, 2 ≤ bx ≤ 40), where n is the number of digits in the bx-based representation of X.The second line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi < bx) — the digits of X. They are given in the order from the most significant digit to the least significant one.The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 ≤ m ≤ 10,2 ≤ by ≤ 40, bx ≠ by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 ≤ yi < by) — the digits of Y.There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
Output
Output a single character (quotes for clarity):
- '<' if X < Y
- '>' if X > Y
- '=' if X = Y
Sample Input
6 2
1 0 1 1 1 1
2 10
4 7
Sample Output
=
HINT
题意
给你两个在不同进制下的数,然后让你输出a>b还是a=b还是a<b
题解:
数很显然是在longlong范围内的,于是我们就用longlong去模拟就好了
代码:
#include<iostream>
#include<stdio.h>
using namespace std; long long a,b;
long long n,t;
int main()
{
cin>>n>>t;
for(int i=;i<n;i++)
{
long long temp;cin>>temp;
a = a*t+temp;
}
cin>>n>>t;
for(int i=;i<n;i++)
{
long long temp;cin>>temp;
b = b*t+temp;
}
if(a>b)cout<<">"<<endl;
else if(a<b)cout<<"<"<<endl;
else cout<<"="<<endl;
}
Codeforces Round #333 (Div. 2) A. Two Bases 水题的更多相关文章
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
- Codeforces Round #335 (Div. 2) B. Testing Robots 水题
B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...
- Codeforces Round #306 (Div. 2) A. Two Substrings 水题
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...
- Codeforces Round #188 (Div. 2) A. Even Odds 水题
A. Even Odds Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/problem/ ...
随机推荐
- 【MySQL】Java对SQL时间类型的操作(获得当前、昨天、前年。。时间)
Java获得当前时间 java.util.Date date = new java.util.Date(); Timestamp time = new Timestamp(date.getTime() ...
- PostgreSQL 8.4.1
PHP100资讯:PostgreSQL 是一种对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大.特性最丰富和最复杂的自由软件数据库系统.它起源于伯克利(BSD)的数据库研究计划,目前是最 ...
- android模块化app开发-3远程动态更新插件
前两章用apkplug框架实现了两个基本的功能,但它们都是在本地安装测试的,在实际开发过程中我们肯定是需要与服务器联网将更新的插件远程推送给用户手机客户端.今天利用apkplug提供的插件托管服务轻松 ...
- 程序破解之 API HOOK技术 z
API HOOK,就是截获API调用的技术,在程序对一个API调用之前先执行你的函数,然后根据你的需要可以执行缺省的API调用或者进行其他处理,假设如果想截获一个进程对网络的访问,一般是几个socke ...
- 《Python 学习手册4th》 第十四章 迭代器和解析
''' 时间: 9月5日 - 9月30日 要求: 1. 书本内容总结归纳,整理在博客园笔记上传 2. 完成所有课后习题 注:“#” 后加的是备注内容 (每天看42页内容,可以保证月底看完此书) “重点 ...
- python学习资源
12岁的少年教你用Python做小游戏: http://blog.jobbole.com/46308/ python视频教程大全集: http://www.douban.com/group/topic ...
- 如何在 Windows Azure 的虚拟机 ubuntu 上面安装和配置 openVPN(一)
这篇文章,既是写给大伙儿的,也是写给自己的.本文要求读者需要有一定的英文基础和动手能力. 因为有MSDN subscriptions,所以每个月有100$可以使用windows azure,于是想尝试 ...
- bzoj 3732 Network(最短路+倍增 | LCT)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3732 [题意] 给定一个无向图,处理若干询问:uv路径上最长的边最小是多少? [思路一 ...
- 如何用chrome修改js代码,跳过网站等待时间
用chrome修改js代码 By Z.H. Fu 切问录 [maplewizard.github.io](http://maplewizard.github.io ) 网页中大部分的限制都是由js编写 ...
- 分类算法之朴素贝叶斯分类(Naive Bayesian Classification)
1.什么是分类 分类是一种重要的数据分析形式,它提取刻画重要数据类的模型.这种模型称为分类器,预测分类的(离散的,无序的)类标号.例如医生对病人进行诊断是一个典型的分类过程,医生不是一眼就看出病人得了 ...