cf602A Two Bases
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.
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 a single character (quotes for clarity):
- '<' if X < Y
- '>' if X > Y
- '=' if X = Y
6 2
1 0 1 1 1 1
2 10
4 7
=
3 3
1 0 2
2 5
2 4
<
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
>
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的更多相关文章
- TypeError: 'bases' is null or not an object。IE8 bug 腐朽的对象
使用Webapp Builder时候发现,在IE8上很奇怪的一个现象:在ajax回调函数中引用一个闭包作用域链中的对象作为某一个Dijit的实例化参数时有问题:bases is null or not ...
- 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 ...
- 【CodeForces 602A】C - 特别水的题3-Two Bases
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/C Description After seeing the ...
- UVALive 4225 Prime Bases 贪心
Prime Bases 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&a ...
- 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/ ...
- A. Two Bases
A. Two Bases time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- SAP CRM Installed Bases(IBase)简介
SAP CRM使用Installed Base(以下简称IBase)来组织服务相关对象并进行管理.因为我在最近的工作中经常接触这个概念,所以学习了一点相关文档.下面是文档的翻译. 本文链接:https ...
- 《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 ...
- 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 ...
随机推荐
- Android 巧妙实现图片和文字上下布局或者左右布局
最近去了一家新公司,然后开始做新的项目,看其代码发现了一个很巧妙的方法来实现图片在上面文字在下面的布局方式.只需要一个控件——RadioButton. 布局文件很简单,用来展示RadioBUtton的 ...
- sql常用的日期函数与应用
--本周第一天 ),getdate()) --or ,) --本周第一天 ,) --上月第一天 ),,,) --上月最后一天 ),,,)),)+' 23:59:59' --本月第一天 ,getdate ...
- 在eclipse下面搭建Clojure开发运行环境
打开eclipse,点击菜单栏“help->Install New Software...", 然后,点击”add“, 在Location处输入 http://ccw.cgrand.n ...
- ssh配置事务
http://blog.csdn.net/jianxin1009/article/details/9202907(不错)
- 设置tomcat启动超时,不会自动停止
tomcat启动时如果1000ms没有起来,服务就会自动停止.设置位置如下
- &与&
- Business Intelligence (BI)
BI, 全称Business Inteligence. 帮助企业更有效地利用数据,提供经营决策支持.让决策管理者随时随地获取关键信息,基于数字决策,最终提高决策水平. 包括范围(层次由低到高):数据报 ...
- Windows程序设计 贪吃蛇c
看Windows程序有段时间了,终于动手写东西.贪吃蛇算是一个开始吧,下面的贪吃蛇很简单,也有很多地方需要修改,还有情况没有考虑QAQ 但这不是我的目的了... 思路很简单:建个链表储存蛇身节点即可. ...
- DX笔记之一---Direct3D基础
一.预备知识 1.表面 表面就是Direct3D用于储存2D图像数据的一个像素矩阵.width和height以像素为单位,pitch以字节单位,用接口IDirect3DSurface来描述表面 Loc ...
- nginx 跨域。。。掉坑里了,小心
今天公司产品一个功能突然挂掉了...向客户演示之前出现了,手机端显示不能获取下载资源,可是急坏了一票人.. 通过手机端,调查服务器地址调用了http:/2342342.domain.hostname. ...