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. [六省联考2017]分手是祝愿(期望+DP)

    题解 很容易想出来最优策略是什么. 就是从n到1看到开着的灯就把它关了 我们预处理出当前状态把灯全部关闭后的最少步数cnt 然后我们的主人公就要瞎按... 设dp[i]代表当前状态最优解为i步时走到d ...

  2. Centos6.6 系统优化

    1:最小化安装 2:修改网卡 vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0HWADDR=52:54:00:0e:c2:c3TYPE ...

  3. Tomcat连HBase报错: HTTP Status 500 - java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext

    Tomcat中连接HBase数据库,启动的时候报错: HTTP Status 500 - java.lang.AbstractMethodError: javax.servlet.jsp.JspFac ...

  4. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  5. ormlite 中的onUpgrade

    public class DBHelper extends OrmLiteSqliteOpenHelper { public static final String DB_NAME = "y ...

  6. Spring MVC登录注册以及转换json数据

    项目结构; 代码如下: BookController package com.mstf.controller; import javax.servlet.http.HttpServletRespons ...

  7. 14个优秀 JS 前端框架、库、工具及其使用时机

    这篇文章主要描述现今流行的一些 Javascript web 前端框架,库以及它们的适用场景. 新的 Javascript 库层出不穷,从而Web 社区愈发活跃.多样.在多方面快速发展.详细去描述每一 ...

  8. 4、Go for循环

    package main import "fmt" func main(){ //for 循环是go语言唯一的循环结构,分为三种类型 //第一种 类似while i:=1 for ...

  9. tf.nn.softmax(logits,name=None)

    tf.nn.softmax( logits, axis=None, name=None, dim=None #dim在后来改掉了 ) 通过Softmax回归,将logistic的预测二分类的概率的问题 ...

  10. webstorm 添加 autoprefixer 工具为CSS加前缀

    webstrom IDE 的 setting (快捷键 Ctrl + Alt  + S) Tool -- External tool (绿色 + 添加) 3.填写 必要的项目 后 apply 备注:N ...