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/ ...
随机推荐
- 【转】./a.out 2>&1 > outfile
原文网址:http://www.cnblogs.com/zhaoyl/archive/2012/10/22/2733418.html APUE 3.5关于重定向有个容易迷惑人的问题: ./a.out ...
- ECshop 每个数据库表结构说明
ecs_account_log // 用户账目日志表 ecs_activity // 活动表(代码,名称,开始,结束,描述) ecs_ad // 广告表(位置,类型,名称,链接,图片,开始,结束,广告 ...
- 浅析android下如何通过jni监控wifi网络连接、dhcpcd执行和power电源控制
libs/android_runtime/android_net_wifi_Wifi.cpp部分jni接口static JNINativeMethod gWifiMethods[] = {{ &quo ...
- 动态 SQL
MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦.拼接的时候要确保不能忘了必要的空格,还要注意省掉 ...
- sql test
1.用户表 找出id=2及他的朋友 select * from user t where id=2 or t.id=(select friend from user where id=2); sele ...
- 【管理工具】Git的安装与使用
公司与公司合并,需要学习一下git的使用.从网上找了一篇资料,完全满足需求,先赞一个. http://www.cnblogs.com/Bonker/p/3441781.html 下面记录一下自己的安装 ...
- 《Python 学习手册4th》 第十五章 文档
''' 时间: 9月5日 - 9月30日 要求: 1. 书本内容总结归纳,整理在博客园笔记上传 2. 完成所有课后习题 注:“#” 后加的是备注内容 (每天看42页内容,可以保证月底看完此书) “重点 ...
- 各个城市优步uber注册司机官网地址汇总
uber城市 开通uber城市 开通优步城市 哪些城市开通了uber 哪些城市开通了优步 分类: uber专车资讯 作为专车模式的创立者,Uber公司很早就进入了中国区域.优步在中国市场也是胸怀大 ...
- 2016传统行业“互联网+”元年,你准备好了吗?
李克强总理在2015年的政府报告中的提出了"互联网+"的概念! 2015年,几十.上百本以"互联网+"作为书名的书出版! 2015年,各种传统行业的信息化被冠上 ...
- C语言-简单哈希表(hash table)
腾讯三面的时候,叫我写了个哈希表,当时紧张没写好···结果跪了··· 回来后粪发涂墙,赶紧写了一个! 什么都不说了···先让我到厕所里面哭一会··· %>_<% 果然现场发挥,以及基础扎实 ...