Codeforces--602A--Two Bases(水)
Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
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
>
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
#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(水)的更多相关文章
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- 【CodeForces 602A】C - 特别水的题3-Two Bases
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/C Description After seeing the ...
- 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/ ...
- 【42.59%】【codeforces 602A】Two Bases
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Two Bases CodeForces - 602A (BigInteger c++long long也可以)
哇咔咔 卡函数的 标记一下 c++和java的进制转换函数都是1-36进制的 c++ long long暴力就过了... 自己写一个就好了 import java.math.BigInteger; i ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- CodeForces 705A(训练水题)
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...
- CodeForces Gym 100685C Cinderella (水题)
题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
随机推荐
- IFC2x3标准阅读
参考地址:西北逍遥-IFC数据模式架构的四个概念层详解说明 1.架构图 IFC模型体系结构由四个层次构成,从下到上依次是 资源层(Resource Layer).核心层(Core Layer).交互层 ...
- java 获取config 配置文件
static ResourceBundle PropertiesUtil = ResourceBundle.getBundle("config"); public static S ...
- Jtester使用
1.在Jtester中使用DataMap 为什么要使用DataMap? 早先的jTester中提供了dbFit方式来准备和验证数据库数据,应该来说,这个工具解决了很多问题.实际使用过程中,开发同学反映 ...
- Object-C,NSSet,不可变集合
又到晚上了,继续码代码. 正在此时,老爸一个电话"海阔凭鱼跃,天高任鸟飞",老爸不在为老问题烦我了. 自由了,突然感觉压力好大啊. 将来混的太惨,可咋办啊- 第1个例子是,不可变集 ...
- 【BZOJ 1293】[SCOI2009]生日礼物
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然的滑动窗口题. (尺取法 如果l..i这一段已经有k种珍珠了. 那么就尝试把l++; (即把l这个影响尝试去掉一下 如果不足k种 ...
- video : Write and Submit your first Linux kernel Patch
http://v.youku.com/v_show/id_XNDMwNzc3MTI4.html After working with Linux (mostly as an advanced user ...
- Object-c Associated Object
oc的关联的作用在我看来就是将两个对象关联起来,用的时候通过key和对象把和这个对象关联的对象再取出来(我做的项目就是和UITableView里面的一个属性关联起来了) 举个栗子: - (void)v ...
- 安卓开发--AsyncTask2
package com.cnn.imageasyncdemo01; import android.app.Activity; import android.content.Intent; import ...
- 微信公众平台开发学习笔记2--获取access token
access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token.获取的access_token过期时间为2小时.获取access token具体说明请参考官方文档. ...
- Idea的一些调试技巧及设置todo
程序员的工作内容,除了大部分时间写代码之外,因为有不少的时间是用在调试代码上.甚至说不是在调试代码,就是即将调试代码. :) 今天我们来谈谈调试代码的一些技巧,在使用IDE提供的debugger时一些 ...