QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#779794#9248. An Easy Math ProblemXiaoYang3TL 1ms3820kbC++231.1kb2024-11-24 21:48:152024-11-24 21:48:15

Judging History

This is the latest submission verdict.

  • [2024-11-24 21:48:15]
  • Judged
  • Verdict: TL
  • Time: 1ms
  • Memory: 3820kb
  • [2024-11-24 21:48:15]
  • 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;
    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; 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});
            }
        }
    }
    cout << se.size() << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3820kb

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: