#5216. [GCJ 2019 Qualification] Foregone Solution

[GCJ 2019 Qualification] Foregone Solution

[GCJ 2019 Qualification] Foregone Solution

题目描述

Someone just won the Code Jam lottery, and we owe them $N$ jamcoins! However, when we tried to print out an oversized check, we encountered a problem. The value of $N$, which is an integer, includes at least one digit that is a `4...` and the 4 key on the keyboard of our oversized check printer is broken.

Fortunately, we have a workaround: we will send our winner two checks for positive integer amounts AA and BB, such that neither AA nor BB contains any digit that is a 4, and A+B=NA + B = N. Please help us find any pair of values AA and BB that satisfy these conditions.

输入格式

The first line of the input gives the number of test cases, $T$. $T$ test cases follow; each consists of one line with an integer $N$.

输出格式

For each test case, output one line containing `Case #x: A B`, where $x$ is the test case number (starting from 1), and $A$ and $B$ are positive integers as described above.

It is guaranteed that at least one solution exists. If there are multiple solutions, you may output any one of them.

3
4
940
4444
Case #1: 2 2
Case #2: 852 88
Case #3: 667 3777

提示

**Sample Explanation**

In Sample Case #1, notice that A and B can be the same. The only other possible answers are 1 3 and 3 1.

Limits

  • 1≤T≤1001 \leq T \leq 100.
  • At least one of the digits of NN is a 4.

Test set 1 (6 Pts, Visible)

  • 1<N<1051 < N < 10^5.

Test set 2 (10 Pts, Visible)

  • 1<N<1091 < N < 10^9.

Solving the first two test sets for this problem should get you a long way toward advancing. The third test set is worth only 1 extra point, for extra fun and bragging rights!

Test set 3 (1 Pts, Hidden)

  • 1<N<101001 < N < 10^{100}. 标签: P13102|数学|2019|Special Judge|Google Code Jam

来源

P13102|[GCJ 2019 Qualification] Foregone Solution