Preparing NOJ

A positive integer $$$a$$$ is given. Baron Munchausen claims that he knows such a positive integer $$$n$$$ that if one multiplies $$$n$$$ by $$$a$$$, the sum of its digits decreases $$$a$$$ times. In other words, $$$S(an) = S(n)/a$$$, where $$$S(x)$$$ denotes the sum of digits of the number $$$x$$$.

Find out if what Baron told can be true.

The only line contains a single integer $$$a$$$ ($$$2 \le a \le 10^3$$$).

If there is no such number $$$n$$$, print $$$-1$$$.

Otherwise print any appropriate positive integer $$$n$$$. Your number must not consist of more than $$$5\cdot10^5$$$ digits. We can show that under given constraints either there is no answer, or there is an answer no longer than $$$5\cdot10^5$$$ digits.

2

6

3

6669

10

-1

Info

Provider CodeForces

Origin Codeforces Round #543 (Div. 1, based on Technocup 2019 Final Round)

Code CF1120E

Tags

brute force

Submitted 46

Passed 4

AC Rate 8.7%

Date 07/21/2019 13:32:17

Related