PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000165. Hàm không chứa bình phương (Square-free Function)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hàm không chứa bình phương (Square-free Function)
Square-free Function
Phuoc Hung OJ problem: PRIME000170
Reference: CodeChef SQUAREFU
Adaptation: one original query per PHOJ execution; subtasks are PHOJ-specific groups.
Problem statement
Given an array of positive integers, let where is the largest perfect square dividing . Count index pairs such that .
Input
The first line contains ; the second line contains integers .
Output
Print one integer: the number of good pairs.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Example
Input
4
2 8 18 3
Output
3
Explanation: The square-free kernels are . Only the three pairs involving the final element have a non-square product, so the answer is .