PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000217. Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)
Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , compute
$$\sum_{1\le i<j\le N}\left\lfloor\frac{\max(A_i,A_j)}{\min(A_i,A_j)}\right\rfloor.$$Count each pair of distinct indices exactly once, including equal values.
Input
The first line contains ; the second line contains integers .
Output
Print the sum as a 64-bit integer.
Subtasks
-
Subtask 1 (20 points): ; .
-
Subtask 2 (30 points): ; .
-
Subtask 3 (50 points): ; .
Examples
Example 1
Input
3
3 1 4
Output
8
Explanation
The three pair contributions are 3, 1, and 4.
Example 2
Input
6
2 7 1 8 2 8
Output
53
Explanation
Equal-valued pairs count separately by index.