CF1326A.Bad Ugly Numbers

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a integer nn (n>0n \gt 0). Find any integer ss which satisfies these conditions, or report that there are no such numbers:

In the decimal representation of ss:

  • s>0s \gt 0,
  • ss consists of nn digits,
  • no digit in ss equals 00,
  • ss is not divisible by any of it's digits.

给你一个整数 nn(n>0n \gt 0)。请找出任意一个满足以下条件的整数 ss;若不存在这样的数,则报告无解:

在 ss 的十进制表示中:

  • s>0s \gt 0,
  • ss 恰好由 nn 位数字组成,
  • ss 中不包含数字 00,
  • ss 不能被其任意一位数字整除。

输入格式

The input consists of multiple test cases. The first line of the input contains a single integer tt (1≤t≤4001 \leq t \leq 400), the number of test cases. The next tt lines each describe a test case.

Each test case contains one positive integer nn (1≤n≤1051 \leq n \leq 10^5).

It is guaranteed that the sum of nn for all test cases does not exceed 10510^5.

输入包含多个测试用例。输入的第一行包含一个整数 tt(1≤t≤4001 \leq t \leq 400),表示测试用例的数量。接下来的 tt 行每行描述一个测试用例。

每个测试用例包含一个正整数 nn(1≤n≤1051 \leq n \leq 10^5)。

保证所有测试用例的 nn 之和不超过 10510^5。

输出格式

For each test case, print an integer ss which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for ss, print any solution.

对于每个测试用例,输出一个满足上述条件的整数 ss;如果不存在这样的数,则输出 “-1”(不带引号)。如果存在多个可能的 ss 解,输出任意一个即可。

输入输出样例

  • 输入#1

    4
    1
    2
    3
    4

    输出#1

    -1
    57
    239
    6789

说明/提示

In the first test case, there are no possible solutions for ss consisting of one digit, because any such solution is divisible by itself.

For the second test case, the possible solutions are: 2323, 2727, 2929, 3434, 3737, 3838, 4343, 4646, 4747, 4949, 5353, 5454, 5656, 5757, 5858, 5959, 6767, 6868, 6969, 7373, 7474, 7676, 7878, 7979, 8383, 8686, 8787, 8989, 9494, 9797, and 9898.

For the third test case, one possible solution is 239239 because 239239 is not divisible by 22, 33 or 99 and has three digits (none of which equals zero).

在第一个测试用例中,不存在由一位数字构成的 ss 的可行解,因为任何这样的解均能被其自身整除。

在第二个测试用例中,可行解包括:2323, 2727, 2929, 3434, 3737, 3838, 4343, 4646, 4747, 4949, 5353, 5454, 5656, 5757, 5858, 5959, 6767, 6868, 6969, 7373, 7474, 7676, 7878, 7979, 8383, 8686, 8787, 8989, 9494, 9797, 和 9898。

在第三个测试用例中,一个可行解是 239239,因为 239239 不能被 22、33 或 99 整除,且它是一个三位数(各位数字均不为零)。

输入解题思路,AI测评打分。不知道怎么写?

首页