Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit
Status

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.

Source

Codeforces Round #333 (Div. 2)

#include<stdio.h>
#include<string.h>
int main()
{
long long A=0,B=0;
int n,b,a;
scanf("%d%d",&n,&b);
for(int i=0;i<n;i++)
{
scanf("%d",&a);
A=A*b+a;
}
scanf("%d%d",&n,&b);
for(int i=0;i<n;i++)
{
scanf("%d",&a);
B=B*b+a;
}
if(A>B)
printf(">\n");
if(A==B)
printf("=\n");
if(A<B)
printf("<\n");
return 0;
}

Codeforces--602A--Two Bases(水)的更多相关文章

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

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

  2. 【CodeForces 602A】C - 特别水的题3-Two Bases

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

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

  4. 【42.59%】【codeforces 602A】Two Bases

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. Two Bases CodeForces - 602A (BigInteger c++long long也可以)

    哇咔咔 卡函数的 标记一下 c++和java的进制转换函数都是1-36进制的 c++ long long暴力就过了... 自己写一个就好了 import java.math.BigInteger; i ...

  6. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  7. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  8. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

  9. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

随机推荐

  1. 地图底图的类型——MapView,SceneView

    MapView用于创建二维地图平面. 引用“esri/Map”,"esri/views/MapView" 具体做法并举例:var map = new Map({basemap:&q ...

  2. POJ 3261 Milk Patterns(后缀数组+单调队列)

    题意 找出出现k次的可重叠的最长子串的长度 题解 用后缀数组. 然后求出heigth数组. 跑单调队列就行了.找出每k个数中最小的数的最大值.就是个滑动窗口啊 (不知道为什么有人写二分,其实写啥都差不 ...

  3. 使用yum配置lnmp环境(CentOS7.6)

    一.安装版本详情 Server: MariaDB Server version: 5.5.60-MariaDB MariaDB Server [root@ln-125 ~]# cat /etc/red ...

  4. nginx.conf.default

    [root@web03 conf]# vim nginx.conf.default #user nobody;worker_processes 1; #error_log logs/error.log ...

  5. JavaScript系列——数组元素左右移动N位算法实现

    引言 在自己刚刚毕业不久的时候,去了一家公司面试,面试官现场考了我这道题,我记忆深刻,当时没有想到思路,毫无疑问被面试官当成菜鸟了.最近刚好在研究数组的各种算法实现,就想到这道题,可以拿来实现一下,纪 ...

  6. python购物车系统

    购物车系统模拟:product_list = [ ('java',100), ('python',200), ('键盘',500), ('电脑',4000), ('mac Book',7000),]S ...

  7. Postman(API & HTTP请求调试插件)

    简述 Postman是一个Chrome扩展,提供功能强大的Web API & HTTP请求调试.它能够发送任何类型的HTTP 请求(GET.HEAD.POST.PUT..),附带任何数量的参数 ...

  8. 3.IntelliJ IDEA 使用详解

    转自:https://blog.csdn.net/wl_627292578/article/details/53796226 目录结构: InteliJ IDEA 没有工作空间的概念 project ...

  9. python-logging写日志编码问题

    python-logging写日志编码问题 标签(空格分隔): python 修改logging.FileHandler() 指定编码格式为:utf8 重新运行

  10. 数位$dp$

    数位\(dp\)搞了一上午才搞懂.靠这种傻\(X\)的东西竟然花了我一上午的时间. 数位\(dp\) 概念 数位\(dp\)就是强制你分类一些数,例如给你一段区间,然后让你求出不包含\(2\)的数的个 ...