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/ ...
随机推荐
- <三>面向对象分析之UML核心元素之参与者
一:版型 --->在UML里有一个概念叫版型.有些书里也称类型,构造型. --->这个概念是对一个UML元素基础定义的扩展.在同一个元素基础定义的基础上赋予特别 ...
- Delphi 函数参数修饰中的var 、out和const
(1)var修饰符 添加var 是地址传递,会修改原有的变量 var s: string; begin S := 'Hello'; ChangeSVar(s); ShowMessage(S); e ...
- 云计算服务模型,第 2 部分: 平台即服务(PaaS)
英文原文:Cloud computing service models, Part 2: Platform as a Service 平台即服务 (PaaS) 常常是最容易让人迷惑的云计算类别,因为很 ...
- c# 进行AE开发时,如何在地图上定位出一个点
一.文本形式的气泡提示框 由于本人是初学,所以具体的含义尚未弄清楚,直接给出代码吧!
- <转>Python学习推荐
书籍推荐 基本了解: <<A Byte of Python>> (Python简明教程http://sebug.net/paper/python/) 网上有资源,两小时了解基本 ...
- LeetCode题解——Palindrome Number
题目: 判断一个数字是不是回文数字,即最高位与最低位相同,次高位与次低位相同,... 解法: 求出数字的位数,然后依次求商和求余判断是否相等. 代码: class Solution { public: ...
- Ajax异步请求PHP数据
来源:http://www.ido321.com/1138.html 接到了老师的一个作业,实现的布局如图: 如果输入了科室ID,科室名字只显示与ID对应的,若没有输入,则显示全部,然后根据I科室名字 ...
- (转载)OC学习篇之---第一个程序HelloWorld
之前的一片文章简单的介绍了OC的相关概述,从这篇开始我们就开始学习OC的相关知识了,在学习之前,个人感觉需要了解的其他的两门语言:一个是C/C++,一个是面向对象的语言(当然C++就是面向对象,不过这 ...
- [Hive - Tutorial] Creating, Showing, Altering, and Dropping Tables
Creating, Showing, Altering, and Dropping Tables See Hive Data Definition Language for detailed info ...
- hive优化之------控制hive任务中的map数和reduce数
一. 控制hive任务中的map数: 1. 通常情况下,作业会通过input的目录产生一个或者多个map任务. 主要的决定因素有: input的文件总个数,input的文件大小,集群设置的 ...