time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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 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
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.

【题目链接】:http://codeforces.com/contest/602/problem/A

【题解】

把它们都转换成10进制再比较就好.
40^10不会爆LL

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)typedef pair<int,int> pii;
typedef pair<LL,LL> pll;const int MAXN = 10+5;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);int n,bx,m,by;
LL a[MAXN];int main()
{//freopen("F:\\rush.txt","r",stdin);rei(n);rei(bx);rep2(i,n-1,0)rel(a[i]);LL x = 0;LL now = 1;rep1(i,0,n-1){x += now*a[i];now = now * bx;}rei(m);rei(by);rep2(i,m-1,0)rel(a[i]);LL y = 0;now = 1;rep1(i,0,m-1){y += now*a[i];now = now * by;}if (x==y)putchar('=');elseif (x < y)putchar('<');elseputchar('>');return 0;
}

转载于:https://www.cnblogs.com/AWCXV/p/7626809.html

【42.59%】【codeforces 602A】Two Bases相关推荐

  1. 【Codeforces】【161Div2】

    [题目来源]http://www.codeforces.com/contest/263 [A. Beautiful Matrix] [解析]模拟即可.按照题目的意思,找到1所在的位置(x, y),然后 ...

  2. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  3. 【codeforces 508B】Anton and currency you all know

    [题目链接]:http://codeforces.com/contest/508/problem/B [题意] 给你一个奇数; 让你交换一次数字; 使得这个数字变成偶数; 要求偶数要最大; [题解] ...

  4. 【codeforces 711B】Chris and Magic Square

    [题目链接]:http://codeforces.com/contest/711/problem/B [题意] 让你在矩阵中一个空白的地方填上一个正数; 使得这个矩阵两个对角线上的和; 每一行的和,每 ...

  5. 【codeforces 807C】Success Rate

    [题目链接]:http://codeforces.com/contest/807/problem/C [题意] 给你4个数字 x y p q 要求让你求最小的非负整数b; 使得 (x+a)/(y+b) ...

  6. 【codeforces 766E】Mahmoud and a xor trip

    [题目链接]:http://codeforces.com/contest/766/problem/E [题意] 定义树上任意两点之间的距离为这条简单路径上经过的点; 那些点上的权值的所有异或; 求任意 ...

  7. 【codeforces 798A】Mike and palindrome

    [题目链接]:http://codeforces.com/contest/798/problem/A [题意] 让你严格改变一个字符,使得改变后的字符串为一个回文串; 让你输出可不可能; [题解] 直 ...

  8. 【37.50%】【codeforces 745B】Hongcow Solves A Puzzle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 796A】Buying A House

    [题目链接]:http://codeforces.com/contest/796/problem/A [题意] 让你选一个最靠近女票的,且能买的房子; 输出你和你女票的距离; [题解] 枚举 [Num ...

最新文章

  1. JDK 8 Stream 数据流效率怎么样?
  2. mysql++月份排序_Mysql 按月份为组进行统计排序_MySQL
  3. 轻松实现SQL Server异地备份
  4. ibm服务器虚拟化报价,IBM x86 服务器虚拟化服务.pdf
  5. bat 存储过程返回值_MySQL-存储过程和函数详述
  6. mysql数据库无法显示中文_mysql数据库不能显示中文是怎么回事呢?
  7. java 爬虫 sessionid_java爬虫实战之模拟登陆
  8. vmplayer虚拟机中如何找到网络配置的窗口
  9. hbase java 建表_Java在HBase数据库创建表
  10. 软件测试预演环境,什么是软件测试用例预演 有何优点?-软件水平考试-考试吧...
  11. Windows如何关闭自动更新
  12. golang-ffmpeg-goav:视频拉流解码成YUVJ420P
  13. 干货:分析学中常用的3种分析方法!
  14. int类型与char类型
  15. 计算机无法重复按键,电脑总是自动重复按键盘上的一个键
  16. GitHub下载加速网站
  17. [zt]怪诞行为学之相对论的真相
  18. 鸡兔同笼:笼子里一共有鸡和兔子35只,一共有94条退, 笼子里一共有鸡和兔子共多少只...
  19. 红图新媒体让你知道提升新媒体广告ROI需要关注的10个指标,
  20. Ubuntu nfs mount 局域网挂载硬盘

热门文章

  1. unity获取电磁笔压感_【WPF】获取电磁笔的压感
  2. 两台linux之间互传php脚本,linux下两台服务器实现同步的方法
  3. 单片机实现环形队列_稀疏数组和队列(二)
  4. altera fpga sdi输出方案_FPGA在电力电子中的应用有哪些?
  5. linux 向程序发送信号,Linux下的信号处理
  6. 笔记本AutoCAD启动时闪退怎么办_戴尔笔记本电脑开不了机如何解决【解决方法】...
  7. LeetCode 295. 数据流的中位数(大小堆)
  8. 屏幕Screen类文件编写
  9. java8 util.time_Java8 java.util.Date转换为java.time.ZonedDateTime
  10. 【机器学习-数据科学】第二节:ipython开发环境搭建以及pandas快速入门