codeforces-scrape

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

1984B.md (1407B)


      1 Source: https://codeforces.com/problemset/problem/1984/B
      2 
      3 B. Large Addition
      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 A digit is large if it is between $5$ and $9$, inclusive. A positive integer is large if all of its digits are large.
     22 
     23 You are given an integer $x$. Can it be the sum of two large positive integers with the same number of digits?
     24 
     25 Input
     26 
     27 The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
     28 
     29 The only line of each test case contains a single integer $x$ ($10 \leq x \leq 10^{18}$).
     30 
     31 Output
     32 
     33 For each test case, output $\texttt{YES}$ if $x$ satisfies the condition, and $\texttt{NO}$ otherwise.
     34 
     35 You can output $\texttt{YES}$ and $\texttt{NO}$ in any case (for example, strings $\texttt{yES}$, $\texttt{yes}$, and $\texttt{Yes}$ will be recognized as a positive response).
     36 
     37 Example
     38 
     39 Input
     40 
     41 ```
     42 11
     43 
     44 1337
     45 
     46 200
     47 
     48 1393938
     49 
     50 1434
     51 
     52 98765432123456789
     53 
     54 11111111111111111
     55 
     56 420
     57 
     58 1984
     59 
     60 10
     61 
     62 69
     63 
     64 119
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 YES
     71 NO
     72 YES
     73 YES
     74 NO
     75 YES
     76 NO
     77 YES
     78 YES
     79 NO
     80 NO
     81 ```
     82 
     83 Note
     84 
     85 In the first test case, we can have $658 + 679 = 1337$.
     86 
     87 In the second test case, it can be shown that no numbers of equal length and only consisting of large digits can add to $200$.
     88 
     89 In the third test case, we can have $696\,969 + 696\,969 = 1\,393\,938$.
     90 
     91 In the fourth test case, we can have $777 + 657 = 1434$.