PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000147. Số xấu đặc biệt (Bad Ugly Numbers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số xấu đặc biệt (Bad Ugly Numbers)
Bad Ugly Numbers
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Find a positive decimal integer of exactly digits, containing no zero digit, that is not divisible by any digit appearing in it. Print -1 if impossible. Print it as a decimal string.
Input
One line with .
Output
An -digit decimal integer, or -1.
Subtask
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Example
Input
3
Output
233
Explanation
The number 233 has three nonzero digits. It is odd, so not divisible by 2, and its digit sum is 8, so it is not divisible by 3.