2022 01.24
https://acs.jxnu.edu.cn/problem/ICPCJX2020Fhttps://acs.jxnu.edu.cn/problem/ICPCJX2020F
Magical Number
神奇的数字啊
1000ms 131072K
描述:
We consider a natural number p with k digits, a1a2..ak¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯(a1≠0)a1a2..ak¯(a1≠0), is magical only when it satisfies:
我们考虑了一个具有 k个数的自然数p,即a1a2。ak(a1)≠0)a1a2。。ak'(a1≠只有在满足以下条件时才具有魔力:
Every number composed by leading digits of p can be divisible by the number of its digits.
由p的前导数字组成的每个数字都可以被其位数整除。
More formally, ∀i∈[1,k]∀i∈[1,k],i|a1a2..ai¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯i|a1a2..ai¯。
通常,∀i∈[1,k]∀i∈[1,k],i|a1a2..ai¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯i|a1a2..ai¯。
For example, 123 is magical, because 1|1, 2|12, 3|123
例如,123是神奇的,因为 1|1, 2|12, 3|123
However,124is not magical, because 3∤124。
然而,124不是神奇的,因为124%3!=0,。
Every digit can be composed with match sticks in the following ways.
每个数字都能用n个火柴棒组成以下的方式;
What is the largest posible magical number you can compose with exactly nn match sticks?
你能用火柴棒创作的最大可能的魔法数字是什么?
输入:
The input contains a integer n(1≤n≤10100)n(1≤n≤10100), the number of match sticks you have .
输入包含一个整数n(1)≤N≤10100)n(1)≤N≤10100),您拥有的火柴棒数量。
输出:
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.
打印最大可能的神奇数字x,它可能由n个火柴棒组成。
如果号码不存在,请打印−1.
样例输入:
3
样例输出:
7
样例输入:
7
样例输出:
74
样例输入:
10000
样例输出:
-1
divisible 可除尽的
digit 数字