PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000236. Đếm cặp không có ước chung xuất hiện (Counting Rhyme)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm cặp không có ước chung xuất hiện (Counting Rhyme)
Đếm cặp không có ước chung xuất hiện (Counting Rhyme)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Count pairs for which there does not exist any array element dividing both and . The witness index may coincide with or .
Input
- First line: integer .
- Second line: array elements.
Output
Print the number of good pairs.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
4
2 3 4 4
Output
3
Explanation
The three good pairs are .
Example 2
Input
4
2 4 4 4
Output
0
Explanation
Each pair has a common divisor equal to 2, which is present in the input.