/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 66ms 15.695 MiB
#2 Wrong Answer 104ms 16.391 MiB

Code

#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 1000000;
long long freq[MAX_N + 1];
long long answers[MAX_N + 1];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Initialize freq to 0
    memset(freq, 0, sizeof(freq));

    // Precompute freq: freq[n] = sum of floor(n/d) for d=1..n
    // Using divisor approach: for each i, add 1 to all multiples j of i
    for (int i = 1; i <= MAX_N; i++) {
        for (int j = i; j <= MAX_N; j += i) {
            freq[j]++;
        }
    }

    // Precompute answers
    for (int n = 1; n <= MAX_N; n++) {
        answers[n] = freq[n] - n;
    }

    int T; cin >> T;
    while (T--) {
        int N; cin >> N;
        cout << answers[N] << "\n";
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1206 D1. GCD equal Absolute Value (Easy Version)
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 16:17:08
Judged At
2025-07-14 16:17:08
Judged By
Score
0
Total Time
104ms
Peak Memory
16.391 MiB