/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 352ms 8.172 MiB
#2 Accepted 378ms 8.77 MiB
#3 Accepted 370ms 8.816 MiB
#4 Accepted 361ms 8.66 MiB
#5 Accepted 362ms 8.918 MiB

Code

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define int long long
const int MOD = 1000000007;
#define sz(x) (ll)(x).size()
#define rd ({ll x; cin >> x; x; })
#define dbg(x) cerr << "[" #x "]  " << (x) << "\n"
// #define errv(x) {cerr << "["#x"]  ["; for (const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
// #define cerr if(0)cerr
#define xx first
#define yy second
mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
/*_________________________________________________________________________________________________________________________*/
ll precalc[1000001];
void Solve()
{
    ll n;
    cin >> n;
    cout << precalc[n] << "\n";
}

int32_t main()
{
    for (ll i = 1; i <= 1000000; i++)
        for (ll j = 2 * i; j <= 1000000; j += i) {
            if (__gcd(j, j - i) == i) {
                precalc[j]++;
            }
        }
    for (ll i = 2; i <= 1000000; i++) {
        precalc[i] += precalc[i - 1];
    }
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": "; // cout << "Case " << i << ": ";
        Solve();
    }
    return 0;
}
// Coded by Tahsin Arafat (@TahsinArafat)

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:48:33
Judged At
2025-07-14 16:48:33
Judged By
Score
100
Total Time
378ms
Peak Memory
8.918 MiB