http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/C

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

Input
6 2
1 0 1 1 1 1
2 10
4 7
Output
=
Input
3 3
1 0 2
2 5
2 4
Output
<
Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
Output
>

Hint

In the first sample, X = 1011112 = 4710 = Y.

In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.

In the third sample,  and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.

转换进制,一边读入一边转为十进制,再比较大小。

#include<stdio.h>
long long x,y,bx,by,num,decx,decy;
int main(){
scanf("%lld%lld",&x,&bx);
for(int i=;i<x-;i++){
scanf("%lld",&num);
decx=(decx+num)*bx;
}
scanf("%lld",&num);
decx=decx+num;
scanf("%lld%lld",&y,&by);
for(int i=;i<y-;i++){
scanf("%lld",&num);
decy=(decy+num)*by;
}
scanf("%lld",&num);
decy=decy+num; if(decx>decy)printf(">\n");
else if(decx<decy)printf("<\n");
else printf("=\n");
return ;
}

  

【CodeForces 602A】C - 特别水的题3-Two Bases的更多相关文章

  1. 【CodeForces 596A】E - 特别水的题5-Wilbur and Swimming Pool

    Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...

  2. 【CodeForces 599A】D - 特别水的题4- Patrick and Shopping

    Description  meter long road between his house and the first shop and a d2 meter long road between h ...

  3. 【 CodeForces 604A】B - 特别水的题2-Uncowed Forces

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/B Description Kevin Sun has jus ...

  4. 【CodeForces 606A】A -特别水的题1-Magic Spheres

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/A Description Carl is a beginne ...

  5. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  6. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  7. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  8. Codeforces 828B Black Square(简单题)

    Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. ...

  9. http://codeforces.com/gym/100623/attachments E题

    http://codeforces.com/gym/100623/attachments E题第一个优化它虽然是镜像对称,但它毕竟是一一对称的,所以可以匹配串和模式串都从头到尾颠倒一下第二个优化,与次 ...

随机推荐

  1. html5 实现video标签的自定义播放进度条

    现在随着html5的渐热,越来越多的web开发者都开始选择使用html5写出一些比较好的web应用. html代码: <!DOCTYPE html> <html lang=" ...

  2. TDD in Expert Python Programmin

    Test-Driven Development PrinciplesTDD consists of writing test cases that cover a desired feature, t ...

  3. MongoDB学习(一)简介

    本篇主要简单介绍一下MongoDB数据库. 一.简介 mongoDB是一个开源的,基于分布式的,面向文档存储的非关系型数据库.是非关系型数据库当中功能最丰富.最像关系数据库的. mongoDB由C++ ...

  4. .Net core Linux环境安装

    10月份的时候在自己电脑上搭了开发环境,当时跑完Welcome后就搁置了一段时间,最近有一个小项目要正式采用core来开发并部署在linux环境下,于是在Linux上也搭建一个运行环境. 虽然不经常使 ...

  5. Thread锁 Monitor类、Lock关键字和Mutex类

    Monitor 类锁定一个对象 当多线程公用一个对象时,也会出现和公用代码类似的问题,这种问题就不应该使用lock关键字了,这里需要用到System.Threading中的一个类Monitor,我们可 ...

  6. react native 底部按钮切换

    在react   native  中底部按钮的切换  主要的是运用的是<TabBarNavigator/>这个组件,具体的代码实现如下: render() { return ( <T ...

  7. nginx缓存模块配置总结proxy_cache(未完)

    简介:此缓存设置用到了第三方模块purge,使用的时候就在源链接和访问的具体内容之间加入关键字"/purge/"即可. 如:访问http://192.168.0.1/a.png 会 ...

  8. C#中 += (s, e) => 这些字符什么意思

    public MainWindow(){InitializeComponent();this.Loaded += (s, e) => DiscoverKinectSensor();this.Un ...

  9. IOS开发之——类似微信摇一摇的功能实现

    首先,一直以为摇一摇的功能实现好高大上,结果百度了.我自己也模仿写了一个demo.主要代码如下: 新建一个项目,名字为AnimationShake. 主要代码: - (void)motionBegan ...

  10. 文本模板转换工具包和 ASP.NET MVC

    http://msdn.microsoft.com/zh-sg/magazine/ee291528.aspx