QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670935#9248. An Easy Math Problemsnow_miku#TL 0ms3532kbC++231.0kb2024-10-24 08:55:282024-10-24 08:55:29

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-24 08:55:29]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3532kb
  • [2024-10-24 08:55:28]
  • Submitted

answer

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

void solve(){
    ll n;
    cin >> n;
    // ll m = sqrt(n);
    vector<ll> num;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){num.push_back(i); if (i != n / i) num.push_back(n/i);}
    }
    sort(num.begin(), num.end());
    // cout << "num: " << num.size() << '\n';

    // vector<pair<ll, ll>> ans;
    ll cnt = 0;
    for(int i = 0; i < num.size(); i++){
        for(int j = i; j < num.size(); j++){
            if (n % (num[i] * num[j]) != 0) continue;
            ll d = __gcd(num[i], num[j]);
            if (d == 1) {
                // ans.push_back({num[i]/d, num[j]/d});
                cnt++;
            }
        }
    }
    // for(int i = 0; i < ans.size(); i ++){
    //     cout << ans[i].first << " " << ans[i].second << endl;
    // }
    // cout << ans.size() << "\n";
    cout << cnt << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    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: 3532kb

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: