/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 1ms 320.0 KiB
#5 Accepted 1ms 500.0 KiB

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 13:21:55
Judged At
2024-11-11 02:33:49
Judged By
Score
100
Total Time
1ms
Peak Memory
500.0 KiB