CF394B.Very Beautiful Number
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Teacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a "very beautiful number". But the problem is, he's left his paper with the number in the teachers' office.
The teacher remembers that the "very beautiful number" was strictly positive, didn't contain any leading zeroes, had the length of exactly p decimal digits, and if we move the last digit of the number to the beginning, it grows exactly x times. Besides, the teacher is sure that among all such numbers the "very beautiful number" is minimal possible.
The teachers' office isn't near and the teacher isn't young. But we've passed the test and we deserved the right to see the "very beautiful number". Help to restore the justice, find the "very beautiful number" for us!
老师认为我们取得了很大进步。现在,我们甚至被允许使用十进制记数法,而不再用小木棍计数了。测验结束后,老师承诺向我们展示一个“极其优美的数”。但问题在于,他把写有这个数的纸留在了教师办公室。
老师记得,“极其优美的数”严格为正,不含前导零,恰好由 p 位十进制数字组成;并且,若将该数的最后一位数字移到最前面,所得新数恰好是原数的 x 倍。此外,老师确信:在所有满足上述条件的数中,“极其优美的数”是最小的那个。
教师办公室离得不近,而且老师年纪也不小了。但我们已经通过了测验,理应有权见到这个“极其优美的数”!请帮我们伸张正义,为我们找出这个“极其优美的数”!
输入格式
The single line contains integers p, x (1 ≤ p ≤ 106, 1 ≤ x ≤ 9).
单行包含整数 p、x(1 ≤ p ≤ 106,1 ≤ x ≤ 9)。
输出格式
If the teacher's made a mistake and such number doesn't exist, then print on a single line "Impossible" (without the quotes). Otherwise, print the "very beautiful number" without leading zeroes.
如果老师犯了错误,使得这样的数不存在,则在一行中输出 "Impossible"(不带引号)。否则,输出这个“极其优美的数”,且不得包含前导零。
输入输出样例
输入#1
6 5
输出#1
142857
输入#2
1 2
输出#2
Impossible
输入#3
6 4
输出#3
102564
说明/提示
Sample 1: 142857·5 = 714285.
Sample 2: The number that consists of a single digit cannot stay what it is when multiplied by 2, thus, the answer to the test sample is "Impossible".
样例 1:142857 × 5 = 714285。
样例 2:仅由一位数字组成的数在乘以 2 后不可能保持不变,因此该测试样例的答案为“不可能”。
输入解题思路,AI测评打分。不知道怎么写?