Accepted
Code
#include <bits/stdc++.h>
using namespace std;
int countPairs(const vector<int>& a) {
int n = a.size();
long long mod = 1e9 + 7;
long long cnt = 0;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
long long product = 1LL * a[i] * a[j];
long long sum = a[i] + a[j];
if (product % sum == 0) {
cnt = (cnt + 1) % mod;
}
}
}
return cnt;
}
int main() {
int N;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; ++i) {
cin >> a[i];
}
int r = countPairs(a);
cout << r << endl;
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1131 Count Special Pairs
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-04 12:38:09
- Judged At
- 2024-11-11 02:33:49
- Judged By
- Score
- 100
- Total Time
- 1ms
- Peak Memory
- 532.0 KiB