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 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
随机推荐
- [六省联考2017]分手是祝愿(期望+DP)
题解 很容易想出来最优策略是什么. 就是从n到1看到开着的灯就把它关了 我们预处理出当前状态把灯全部关闭后的最少步数cnt 然后我们的主人公就要瞎按... 设dp[i]代表当前状态最优解为i步时走到d ...
- 仿射变换(Affine Transformation)
转自:https://www.cnblogs.com/bnuvincent/p/6691189.html http://www.cnblogs.com/ghj1976/p/5199086.html 变 ...
- 洛谷 P1220 关路灯 (贪心+区间dp)
这一道题我一直在想时间该怎么算. 看题解发现有个隐藏的贪心. 路径一定是左右扩展的,左右端点最多加+1(我竟然没发现!!) 这个性质非常重要!! 因此这道题用区间dp f[i][j]表示关完i到j的路 ...
- 【BZOJ 1588】 [HNOI2002]营业额统计
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每天的最小波动值指的是和之前所有天的差值的绝对值中的最小值. 用set.的lower_bound函数. 每次找和他差值最小的数字就好 ...
- Ruby创建命令
Ruby创建命令
- hdu2236
链接:点击打开链接 题意:在一个n*n的矩阵中,找n个数使得这n个数都在不同的行和列里而且要求这n个数中的最大值和最小值的差值最小 代码: #include <iostream> #inc ...
- 从Oracle Database 角度来看浪潮天梭K1主机的操作系统选择
背景: 浪潮天梭k1主机.事实上分好几个类别: K1-950 intel 安腾cpu K1-930 intel 安腾cpu K1-910 intel 安腾cpu K1-800 intel 志强cpu ...
- WebView Js注入
注入前: 注入后: 主界面: package com.example.webviewjsdemo; import android.os.Bundle; import android.app.Activ ...
- 搭建Mysql双机热备 (主从同步)
准备两台centos7主机:10.0.18.132 master 10.0.18.136 slave 先把selinux关闭,iptables关闭 或者添加端口 132 master安装好Mysq ...
- 【J-meter】正则表达式提取
当获取的值中含有折行,可采用下面的办法解决: