描述:
We consider a natural number p with k digits, a1a2..ak¯(a1≠0), is magical only when it satisfies:
Every number composed by leading digits of p can be divisible by the number of its digits.
More formally, ∀i∈[1,k],i|a1a2..ai¯。
For example, 123 is magical, because 1|1, 2|12, 3|123。
However,124 is not magical, because 3∤124。
Every digit can be composed with match sticks in the following ways.
What is the largest posible magical number you can compose with exactly n match sticks?
输入:
The input contains a integer n(1≤n≤10100), the number of match sticks you have .
输出:
Print the largest posible magical number x that can be possibly composed with exactly n match sticks.
If the number doesn't exist, print −1.
样例输入:
3
样例输出:
7
样例输入:
7
样例输出:
74
样例输入:
10000
样例输出:
-1
描述:
我们认为一个有k个数字的自然数p,a1a2..ak¯(a1≠0),是有魔法的,当它满足:
每一个由开头数字为p组成的数字可以被这个数字的位数整除。
更正式的说,∀i∈[1,k],i|a1a2..ai¯。
例如,123是有魔法的,因为1|1, 2|12, 3|123。
不过,124是没有魔法的,因为3∤124。
每一个数字都可以用火柴棒由以下方法组成。
用具体的n根火柴棒,你能组成的最大的可能有魔法的数字是什么?
输入:
输入包含一个整数n(1≤n≤10100),为你有的火柴棒的数量。
输出:
输出可能被具体的n根火柴棒组成的可能有魔法的数字x。
如果这个数不存在,输出-1。