PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SCKT0000001. Chia hết cho 3 nhưng không chia hết cho 5 (Multiples of 3 but Not 5)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Đang đọc
Chia hết cho 3 nhưng không chia hết cho 5 (Multiples of 3 but Not 5)
Multiples of 3 but Not 5
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a positive integer .
Consider every integer from to . An integer is selected if both of the following conditions hold:
- is divisible by ;
- is not divisible by .
Equivalently, find all integers satisfying
$$1 \le x \le n,\qquad x \bmod 3 = 0,\qquad x \bmod 5 \ne 0.$$Print all selected integers in increasing order.
Input
One line containing the integer .
Output
Print all integers satisfying the conditions on one line, in increasing order. Consecutive numbers must be separated by exactly one space.
If no integer satisfies the conditions, print an empty line.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Input
20
Output
3 6 9 12 18
Explanation
The multiples of in are . The number is also divisible by , so it is excluded. Therefore the answer is .
Liên quan
Trong các cuộc thi sau: