QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#684674 | #9531. Weird Ceiling | ticking_away# | WA | 1ms | 3620kb | C++20 | 1.3kb | 2024-10-28 15:09:09 | 2024-10-28 15:09:09 |
Judging History
answer
#include <bits/stdc++.h>
#define con const
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
#define i128 __int128_t
using u32 = uint32_t;
using u64 = uint64_t;
using f64 = long double;
template<class T>
using lque = priority_queue<T, vector<T>, greater<T>>;
template<class T>
using gque = priority_queue<T>;
template<class T>
void mes(T * arr, u32 n, int val) {
memset(arr, val, n*sizeof(T));
}
template<class T>
vector<u32> fac(T x) {
if(x==1) return {1};
vector<u32> pri = {1, x};
T i;
u32 lim = sqrt(x);
for(i=2; i<lim; ++i) {
if(x%i==0) {
pri.push_back(i);
pri.push_back(x/i);
}
}
if(x%i==0) {
pri.push_back(i);
if(i*i!=x) pri.push_back(i);
}
return pri;
}
// -------------------
con i32 MX = 1e5 + 7;
u32 ip;
void solve() {
auto vec = fac(ip);
sort(vec.begin(), vec.end());
u32 sz = vec.size();
u64 ans = 0;
vec.push_back(ip+1);
for(u32 i=0; i<sz; ++i) {
ans += u64(ip/vec[i])*(vec[i+1]-vec[i]);
}
cout << ans << '\n';
}
void pre() {
cin >> ip;
}
u32 _t = 1;
void init() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> _t;
}
int main() {
init();
for(;_t--;) {
pre();
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
3 5 451 114514
output:
21 10251 7075858
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3620kb
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 3 7 9 21 19 43 33 37 36 111 43 157 64 91 65 273 73 343 91 113 144 507 105 201 196 163 134 813 141 931 161 221 324 351 169 1333 400 287 205 1641 225 1807 254 277 576 2163 249 589 301 443 326 2757 298 507 323 533 900 3423 315 3661 1024 463 385 625 386 4423 494 737 437 4971 397 5257 1444 551 590 969 ...
result:
wrong answer 6th lines differ - expected: '16', found: '19'