codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

602A.md (2272B)


      1 Source: https://codeforces.com/problemset/problem/602/A
      2 
      3 A. Two Bases
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 You're given a number *X* represented in base *b**x* and a number *Y* represented in base *b**y*. Compare those two numbers.
     24 
     25 Input
     26 
     27 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*.
     28 
     29 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.
     30 
     31 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*.
     32 
     33 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.
     34 
     35 Output
     36 
     37 Output a single character (quotes for clarity):
     38 
     39 * '<' if *X* < *Y*
     40 * '>' if *X* > *Y*
     41 * '=' if *X* = *Y*
     42 
     43 Examples
     44 
     45 Input
     46 
     47 ```
     48 6 2  
     49 1 0 1 1 1 1  
     50 2 10  
     51 4 7
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 =
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 3 3  
     64 1 0 2  
     65 2 5  
     66 2 4
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 <
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 7 16  
     79 15 15 4 0 0 7 10  
     80 7 9  
     81 4 8 0 3 1 5 0
     82 ```
     83 
     84 Output
     85 
     86 ```
     87 >
     88 ```
     89 
     90 Note
     91 
     92 In the first sample, *X* = 1011112 = 4710 = *Y*.
     93 
     94 In the second sample, *X* = 1023 = 215 and *Y* = 245 = 1123, thus *X* < *Y*.
     95 
     96 In the third sample, ![](https://espresso.codeforces.com/603a342b0ae3e56fed542d1c50c0a5ff6ce2cbaa.png) 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*.