All submissions for this problem are available.
Till now, ShadowFiddle company is using off-the-shelf encryption software like PGP but they faced some problems like the executive officer sometimes failed to send each other encrypted messages, which are extremely urgent and secure, so company has tasked the IT staff to handle this problem
Your friend Mr. Shukla in the company is a wonderful person but a not-so-wonderful programmer. He has created a public-private key scheme as follows. A public key can be any positive integer. The corresponding private key is the smallest bipartile number that is greater than a multiple of the public key.
A bipartile number is any positive integer that contains exactly 2 distinct decimal digits s and t such that s is not 0 and all occurences of s precede all occurences of t. For example 44444411 is bipartile (s is 4 and t is 1), so are 41, 10000000 and 5555556. However, neither 4444114 nor 44444 are bipartile.
Notice that the large bipartite number 88888888888800000 can be described as 12 8's followed by 5 0's. You can express any bipartite number using four numbers: m s n t. The numbers s and t are the leading and trailing digits as described above, m is the number of times the digit s appears in the bipartite number, and n is the number of times the digit t apppears.
The trouble with Mr. shukla's scheme is that it is not too difficult to compute a private key if you know the public key. You need to convince your friend that his public-private key scheme is inadequate before he loses his job over his bad decision! You must write a program that takes public keys as input and displays the corresponding private keys
The input consists of several test cases. Each test case is on a separate line, and it consists of a single public key in the range 1...99999.
The last case is followed by a line containing the integer zero.
For each test case, display a line consists of a public key, a colon, then 4 integer m s n t where m, n, s, and t are as described above.
Input: 125 17502 2005 Output: 125: 1 5 2 0 17502: 4 7 4 8 2005: 3 2 3 5
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.