QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697428 | #9531. Weird Ceiling | CangShuV# | WA | 1ms | 3636kb | C++23 | 1.2kb | 2024-11-01 14:02:54 | 2024-11-01 14:02:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// int cal(int a, int i) {
// while (i >= 2) {
// if (a % i == 0)
// return a / i;
// --i;
// }
// return a;
// }
vector<int> stk;
void divide(int n) {
int p = sqrt(n);
for (int i = 1; i < p; ++i) {
if (n % i == 0)
stk.emplace_back(i), stk.emplace_back(n / i);
}
if (p * p == n)
stk.emplace_back(p);
}
void solve() {
ll n;
ll sum = 0;
cin >> n;
if (n == 1) {
cout << 1 << '\n';
return;
}
sum = 1;
stk.clear();
divide(n);
sort(stk.begin(), stk.end());
// for (auto &it : stk) {
// // cout << it << ' '; // ft.
// sum -= n;
// sum += n / it;
// }
// for (auto &it : stk){
// cout << it << ' '; // ft.
// }
for (int i = 1; i < stk.size(); ++i) {
sum += (1ll * (stk[i] - stk[i - 1])) * n / stk[i - 1];
}
cout << sum << "\n";
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
while (n--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
3 5 451 114514
output:
21 10251 7075858
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3636kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
1 1 1 9 21 31 43 57 37 36 111 49 157 64 211 65 273 73 343 121 113 144 507 113 201 196 163 134 813 161 931 161 221 324 1191 169 1333 400 287 205 1641 281 1807 254 277 576 2163 273 589 301 443 326 2757 298 507 365 533 900 3423 315 3661 1024 631 385 625 386 4423 494 737 437 4971 409 5257 1444 551 590 9...
result:
wrong answer 2nd lines differ - expected: '3', found: '1'