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 水题的更多相关文章

  1. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. 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 ...

  3. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  4. 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 ...

  5. Codeforces Round #146 (Div. 1) A. LCM Challenge 水题

    A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...

  6. 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 ...

  7. 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/ ...

  8. 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 ...

  9. 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/ ...

随机推荐

  1. 【Ajax】实现注册页面判断用户名是否可用的提示—异步加载

    效果如图 在注册或登录网站时,当我们输入错误格式的账号或信息时,会看到这种提示. 那怎么实现呢,通过ajax异步加载的方式,可以实现不刷新页面就显示出该提示. 实现 首先创建一个JSP,写一个简单的页 ...

  2. 【树状数组(二叉索引树)】轻院热身—candy、NYOJ-116士兵杀敌(二)

    [概念] 转载连接:树状数组 讲的挺好. 这两题非常的相似,查询区间的累加和.更新结点.Add(x,d) 与 Query(L,R) 的操作 [题目链接:candy] 唉,也是现在才发现这题用了这个知识 ...

  3. Ruby基础数据类型

    #数字分为证书Integer,浮点数Float(对应与其他语言中的double),和复数Complex #整数又分为Fixnum和Bignum,Fixnum和Bignum会互相转换,这些都是ruby自 ...

  4. Grep 命令 用法大全

    查找x文件 find / -name "x*" -ls 查找文件中x所在的行数 grep -n "x" -r *find . -name "*.jav ...

  5. NSThread 多线程相关

    1.下面的代码,有2点需要注意,1>就是 就是thread:所传得参数,这里传得的是nsarray 当然也可以传其他的类型.2> [self performSelectorOnMainTh ...

  6. 帮同事写了几行代码,在 安装/卸载 程序里 注册/卸载 OCX控件

    写了个小控制台程序,这个程序用来注册 / 卸载OCX控件,用在Inno Setup做的安装卸载程序里. #include "stdafx.h" #include <windo ...

  7. Canvas入门(3):图像处理和绘制文字

    来源:http://www.ido321.com/997.html 一.图像处理(非特别说明,所有结果均来自最新版Google) 在HTML 5中,不仅可以使用Canvas API绘制图形,也可以用于 ...

  8. 瞬间从IT屌丝变大神——HTML规范

    HTML规范包含以下内容: DTD统一用<!DOCTYPE HTML PUBLIC "_//W3C//DTD XHTML 1.0 Transitional//EN"" ...

  9. 恒天云 3.0:打造基于OpenStack的私有云新模式

    摘自恒天云官网:http://www.hengtianyun.com/download-show-id-17.html 云计算在当今IT世界中已发展地如火如荼,越来越多的企业利用云计算改造传统的数据中 ...

  10. list、tuple、dict、set、map

    list Python内置的一种数据类型是列表. list是一种有序的集合,可以随时添加和删除其中的元素. # 创建list classmate = ['micheal', 'Bob', 'Tracy ...