QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779786#9248. An Easy Math ProblemXiaoYang3WA 0ms3596kbC++231.2kb2024-11-24 21:46:492024-11-24 21:46:49

Judging History

This is the latest submission verdict.

  • [2024-11-24 21:46:49]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3596kb
  • [2024-11-24 21:46:49]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
using pii = pair<ll, ll>;
ll n, m, k;
const ll P = 998244353;
map<int, int> mp;
void solve() {
    cin >> n;
    if (mp[n]) {
        cout << mp[n] << '\n';
        return;
    }
    vector<ll> v1;
    // set<long double> se;
    for (int i = 1; i <= n / i; i++) {
        if (n % i == 0) {
            v1.push_back(i);
            v1.push_back(n / i);
        }
    }
    //cout << v1.size() << ' ';
    sort(v1.begin(), v1.end());
    set<pii> se;
    for (int i = 0; i < v1.size(); i++) {
        for (int j = i + 1; j < v1.size(); j++) {
            ll x = v1[i], y = v1[j];
            if (y % x == 0) {
                ll xx = x, yy = y / x;
                if (xx < yy) {
                    swap(xx, yy);
                }
                ll d = __gcd(xx, yy);
                se.insert({xx / d, yy / d});
            }
        }
    }

    mp[n] = se.size();
    cout << se.size() << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3596kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
1
1
3
1
4
1
4
3
4

result:

wrong answer 2nd lines differ - expected: '2', found: '1'