PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000130. Những cặp chỉ số đẹp (Another Problem about Beautiful Pairs)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Những cặp chỉ số đẹp (Another Problem about Beautiful Pairs)
Another Problem about Beautiful Pairs
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , count pairs satisfying and .
PHOJ single-case adaptation: Each input file contains one case, without the leading test-case count used in the original Codeforces statement. The full per-case size limits remain unchanged.
Input
- First line: .
- Second line: integers .
Output
One integer: the number of valid pairs.
Subtasks
- Subtask 1 (10 points): , .
- Subtask 2 (20 points): , .
- Subtask 3 (30 points): , .
- Subtask 4 (40 points): , (full single-case limits).
Examples
Example 1
Input
5
1 1 2 100 4
Output
3
Explanation: The pairs are .
Example 2
Input
6
2 2 1 1 2 2
Output
7
Explanation: The pairs are .
Example 3
Input
10
1 1 2 3 4 1 1 7 3 9
Output
10
Explanation: The ten valid pairs are , , , , , , , , , and .
Example 4
Input
2
1000000000 1000000000
Output
0
Explanation: The product for the only pair is , while its index distance is .