MY MEMO
[Google Code Jam]2016_Qualification Round_ProblemC_Coin Jam 본문
[Google Code Jam]2016_Qualification Round_ProblemC_Coin Jam
l_j_yeon 2017. 3. 28. 21:12문제 출처 : https://code.google.com/codejam/contest/6254486/dashboard#s=p2
Problem
A jamcoin is a string of N ≥ 2 digits with the following properties:
- Every digit is either
0
or1
. - The first digit is
1
and the last digit is1
. - If you interpret the string in any base between 2 and 10, inclusive, the resulting number is not prime.
Not every string of 0
s and 1
s is a jamcoin. For example, 101
is not a jamcoin; its interpretation in base 2 is 5, which is prime. But the string 1001
is a jamcoin: in bases 2 through 10, its interpretation is 9, 28, 65, 126, 217, 344, 513, 730, and 1001, respectively, and none of those is prime.
We hear that there may be communities that use jamcoins as a form of currency. When sending someone a jamcoin, it is polite to prove that the jamcoin is legitimate by including a nontrivial divisor of that jamcoin's interpretation in each base from 2 to 10. (A nontrivial divisor for a positive integer K is some positive integer other than 1 or K that evenly divides K.) For convenience, these divisors must be expressed in base 10.
For example, for the jamcoin 1001
mentioned above, a possible set of nontrivial divisors for the base 2 through 10 interpretations of the jamcoin would be: 3, 7, 5, 6, 31, 8, 27, 5, and 77, respectively.
Can you produce J different jamcoins of length N, along with proof that they are legitimate?
Input
The first line of the input gives the number of test cases, T. T test cases follow; each consists of one line with two integers N and J.
Output
For each test case, output J+1 lines. The first line must consist of only Case #x:
, where x
is the test case number (starting from 1). Each of the last J lines must consist of a jamcoin of length N followed by nine integers. The i-th of those nine integers (counting starting from 1) must be a nontrivial divisor of the jamcoin when the jamcoin is interpreted in base i+1.
All of these jamcoins must be different. You cannot submit the same jamcoin in two different lines, even if you use a different set of divisors each time.
Limits
T = 1. (There will be only one test case.)
It is guaranteed that at least J distinct jamcoins of length N exist.
Small dataset
N = 16.
J = 50.
Large dataset
N = 32.
J = 500.
'ALGORITHM > ALGORITHM STUDY' 카테고리의 다른 글
[DATASTRUCTURE] Heap Sort (0) | 2017.03.30 |
---|---|
[DATASTRUCTURE] Binary Tree & Binary Search Tree (0) | 2017.03.30 |
[ALGOSPOT] RATIO 승률 올리기 (0) | 2017.02.25 |
[ALGOSPOT] ROUTING 신호 라우팅 (0) | 2017.02.25 |
[DATASTRUCTURE] DFS, BFS (0) | 2017.02.25 |