QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779794 | #9248. An Easy Math Problem | XiaoYang3 | TL | 1ms | 3820kb | C++23 | 1.1kb | 2024-11-24 21:48:15 | 2024-11-24 21:48:15 |
Judging History
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...