QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617161#9248. An Easy Math Problemcastc#TL 0ms3612kbC++201.7kb2024-10-06 14:13:192024-10-06 14:13:19

Judging History

This is the latest submission verdict.

  • [2024-10-31 22:36:43]
  • hack成功,自动添加数据
  • (/hack/1098)
  • [2024-10-31 22:13:58]
  • hack成功,自动添加数据
  • (/hack/1096)
  • [2024-10-31 22:00:43]
  • hack成功,自动添加数据
  • (/hack/1095)
  • [2024-10-06 14:13:19]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3612kb
  • [2024-10-06 14:13:19]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define int long long
vector<int> minp, primes;

void sieve(int n) {
    minp.assign(n + 1, 0);
    primes.clear();
    
    for (int i = 2; i <= n; i++) {
        if (minp[i] == 0) {
            minp[i] = i;
            primes.push_back(i);
        }
        
        for (auto p : primes) {
            if (i * p > n) {
                break;
            }
            minp[i * p] = p;
            if (p == minp[i]) {
                break;
            }
        }
    }
}

void solve() {
    int n;
    cin >> n;
    // n = 10000000000;
    vector<int> a;
    vector<int> c;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            a.push_back(i);
            // if(minp[i]  i) {
                // c.push_back(i);
            // }
            if(i * i != n) {
                // if(minp[n / i] == n / i) {
                    // c.push_back(n / i);
                // }
                a.push_back(n / i);
            }
        }
    }
    sort(a.begin(), a.end());
    set<pair<int, int>> st;
    for(auto x : a) {
        for(auto y : a) {
            if(y * y > x) break;
            if(x % y == 0) {
                int X = x / y, Y = y;
                int G = gcd(X, Y);
                X /= G, Y /= G;
                st.insert({X, Y});
            }
        }
    }
    cout << (int)st.size() << "\n";
}        
    
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // sieve((int)1e5 + 9);
    int T = 1;
    cin >> T;
    while(T--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
3
2
5
2
4
3
5

result:

ok 10 lines

Test #2:

score: -100
Time Limit Exceeded

input:

2000
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
646969323...

output:


result: