PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000139. Ngày trọng đại của Bash (Bash’s Big Day)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ngày trọng đại của Bash (Bash’s Big Day)
Bash's Big Day
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Bash visits Professor Zulu to select Pokémon. There are Pokémon, and the -th has a positive integer strength . Bash may choose any subset.
A group containing at least two Pokémon will fight if the GCD of their strengths equals . A single Pokémon is always allowed, even when its strength is . Find the maximum number of Pokémon Bash can select without a fight.
Input
The first line contains ; the second contains the strengths .
Output
Print one integer: the maximum number of Pokémon Bash can select.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5
2 3 4 6 7
Output
3
Explanation
Choosing strengths gives GCD , so three Pokémon can be taken together. Every group of four has GCD , hence the optimum is three.