CF602A.Two Bases

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 b__x and a number Y represented in base b__y. Compare those two numbers.

在第一次看到“All Your Base Are Belong To Us”这一网络迷因后,数字 X 和 Y 意识到它们使用了不同的进制,这使得它们之间的关系变得复杂。

你将得到一个以 b__x 进制表示的数 X,以及一个以 b__y 进制表示的数 Y。请比较这两个数的大小。

输入格式

The first line of the input contains two space-separated integers n and b__x (1 ≤ n ≤ 10, 2 ≤ b__x ≤ 40), where n is the number of digits in the b__x-based representation of X.

The second line contains n space-separated integers _x_1, _x_2, ..., x__n (0 ≤ x__i < b__x) — 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 b__y (1 ≤ m ≤ 10, 2 ≤ b__y ≤ 40, b__x ≠ b__y), where m is the number of digits in the b__y-based representation of Y, and the fourth line contains m space-separated integers _y_1, _y_2, ..., y__m (0 ≤ y__i < b__y) — 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.

输入的第一行包含两个用空格分隔的整数 nn 和 bxb_x(1 ≤ n ≤ 101 \leq n \leq 10,2 ≤ bx ≤ 402 \leq b_x \leq 40),其中 nn 表示 XX 在 bxb_x 进制下的位数。

第二行包含 nn 个用空格分隔的整数 x1, x2, ..., xnx_1,\,x_2,\,...,\,x_n(0 ≤ xi < bx0 \leq x_i < b_x)——即 XX 的各位数字,按从最高位到最低位的顺序给出。

接下来两行以相同方式描述 YY:第三行包含两个用空格分隔的整数 mm 和 byb_y(1 ≤ m ≤ 101 \leq m \leq 10,2 ≤ by ≤ 402 \leq b_y \leq 40,且 bx ≠ byb_x \neq b_y),其中 mm 表示 YY 在 byb_y 进制下的位数;第四行包含 mm 个用空格分隔的整数 y1, y2, ..., ymy_1,\,y_2,\,...,\,y_m(0 ≤ yi < by0 \leq y_i < b_y)——即 YY 的各位数字。

输入中不会出现前导零。XX 和 YY 均为正整数。两个数的所有数字均以标准十进制数字形式给出。

输出格式

Output a single character (quotes for clarity):

  • '<' if X < Y
  • '>' if X > Y
  • '=' if X = Y

输出一个字符(引号仅用于清晰显示):

  • < 若 X<YX < Y
  • > 若 X>YX > Y
  • = 若 X=YX = Y

输入输出样例

  • 输入#1

    6 2
    1 0 1 1 1 1
    2 10
    4 7

    输出#1

    =
  • 输入#2

    3 3
    1 0 2
    2 5
    2 4

    输出#2

    &lt;
  • 输入#3

    7 16
    15 15 4 0 0 7 10
    7 9
    4 8 0 3 1 5 0

    输出#3

    &gt;

说明/提示

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 b__x is much larger than b__y, so X is clearly larger than Y.

在第一个样例中,X=1011112=4710=YX = 101111_2 = 47_{10} = Y。

在第二个样例中,X=1023=215X = 102_3 = 21_5 且 Y=245=1123Y = 24_5 = 112_3,因此 X<YX < Y。

在第三个样例中, 且 Y=48031509Y = 48031509。我们可以注意到,XX 的高位数字明显更大,且 bxb_x 远大于 byb_y,因此 XX 明显大于 YY。

输入解题思路,AI测评打分。不知道怎么写?

首页