A. Two Bases
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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 thebx-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
Examples
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
>
Note

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.

闲来无事自己找了一场div2做做

第一题进制转换没开longlong就跪了一次。。

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<){printf("-");a=-a;}
if (a>=)write(a/);
putchar(a%+'');
}
inline void writeln(LL a){write(a);printf("\n");}
LL s[];
LL a,b;
inline void getn(LL &a)
{
LL x=read(),y=read(),z=1ll;
for (int i=;i<=x;i++)s[i]=read();
for (int i=x;i>=;i--)a+=s[i]*z,z*=y;
}
int main()
{
getn(a);
getn(b);
if (a==b)puts("=");
if (a<b)puts("<");
if (a>b)puts(">");
}

cf602A

cf602A Two Bases的更多相关文章

  1. TypeError: 'bases' is null or not an object。IE8 bug 腐朽的对象

    使用Webapp Builder时候发现,在IE8上很奇怪的一个现象:在ajax回调函数中引用一个闭包作用域链中的对象作为某一个Dijit的实例化参数时有问题:bases is null or not ...

  2. extracting lines bases a list using awk

    extracting lines bases a list using awk awk 'NR==FNR{a[$1]=$0; next}($1 in a){print a[$1]"\n&qu ...

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

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

  4. UVALive 4225 Prime Bases 贪心

    Prime Bases 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&a ...

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

  6. A. Two Bases

    A. Two Bases time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. SAP CRM Installed Bases(IBase)简介

    SAP CRM使用Installed Base(以下简称IBase)来组织服务相关对象并进行管理.因为我在最近的工作中经常接触这个概念,所以学习了一点相关文档.下面是文档的翻译. 本文链接:https ...

  8. 《Mem2Seq: Effectively Incorporating Knowledge Bases into End-to-EndTask-Oriented Dialog Systems》

    Multihop Attention Networks (MANs) https://zhuanlan.zhihu.com/p/52067672 https://blog.csdn.net/qq_38 ...

  9. Painful Bases LightOJ - 1021

    Painful Bases LightOJ - 1021 题意:给出0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F中的一些字符(不重复)还有一个进制base,求这些字符的排列形成的ba ...

随机推荐

  1. Weex 初始

    1.一旦数据和模板绑定,数据的变化会立即体现在前台的变化 <template> <container> <text style="font-size: {{si ...

  2. Axiom3D学习日记 3.Cameras, Lights, and Shadows

    Camera 相机: 相机基础知识不写了,需要注意的是:axiom目前不支持同时操作多个相机. 创建,设置位置基本操作. _camera = _scene.CreateCamera("Mai ...

  3. tomcat 正常启动,无法访问。且项目启动无问题。。。的解决办法。。

    Eclipes解决方法: 1.右击项目,选择propreties选项 2.在弹出的首选项窗口的左侧选择“Web Project Settings” 3.修改context root:输入框,修改成自己 ...

  4. FluentNHibernate当数据库设置默认值时,使用插入操作,导致默认值没有写入问题

    需要再映射属性字段增加Not.Insert() Map(x => x.Provrince, "PROVRINCE").Not.Insert(); Map(x => x. ...

  5. Deep Learning 学习随记(八)CNN(Convolutional neural network)理解

    前面Andrew Ng的讲义基本看完了.Andrew讲的真是通俗易懂,只是不过瘾啊,讲的太少了.趁着看完那章convolution and pooling, 自己又去翻了翻CNN的相关东西. 当时看讲 ...

  6. 【转】iOS-Core-Animation-Advanced-Techniques(五)

    原文:http://www.cocoachina.com/ios/20150105/10829.html 图层时间和缓冲 图层时间 时间和空间最大的区别在于,时间不能被复用 -- 弗斯特梅里克 在上面 ...

  7. 【转】iOS- 详解文本属性Attributes

    原文: http://www.cnblogs.com/qingche/p/3574995.html?utm_source=tuicool 1.NSKernAttributeName: @10 调整字句 ...

  8. iOS中ARC内部原理

    ARC会自动插入retain和release语句.ARC编译器有两部分,分别是前端编译器和优化器. 1. 前端编译器 前端编译器会为“拥有的”每一个对象插入相应的release语句.如果对象的所有权修 ...

  9. [转]Delphi调用cmd的两种方法

    delphi调用cmd的两种方法vars:string;begins:='cmd.exe /c '+edit1.Text+' >c:\1.txt';winexec(pchar(s),sw_hid ...

  10. VisualStudio2013内置SQLServer入门

    最近做项目老大要求用到sqlserver,但是这项目的数据库只是本地演示用并不复杂,于是决定试试VisualStudio2013内置的SQLServer.对于这个东西的了解并没有多少,然后项目初学习的 ...