QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#167130 | #5503. Euclidean Algorithm | eikki | WA | 1371ms | 3660kb | C++20 | 822b | 2023-09-07 09:38:47 | 2023-09-07 09:38:48 |
Judging History
answer
#include <iostream>
typedef long long ll;
int main() {
// want y mod y-x to equal gcd(x, y)
// y = d + k(y-x)
// kx+d ky+d
// y' = 1 + k(y' - x')
// kx' + 1 = (k-1)y'
// (mod k-1) x' == -1
// (k-1)a + 1, ka+1
// #(r, k, a) s.t. r(ka + 1) <= n given r, k, a > 0
// now just do it block by block
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int q;
std::cin >> q;
while (q--) {
int n;
ll cnt = 0;
std::cin >> n;
// one-line possible >=<
for (ll i = 1; i <= n; i = 1 + n/(n/i)) for (ll j = 1;
j <= n/i - 1; j = 1 + (n/i - 1) / ((n/i - 1) / j)) cnt += (1 +
(n / (n/i)) - i) * ((1 + (n/i - 1)/((n/i - 1)/j) - j) * ((n/i - 1)/j));
std::cout << cnt << "\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
input:
3 2 5 14
output:
1 9 62
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1371ms
memory: 3660kb
input:
3 29107867360 65171672278 41641960535
output:
526529808500 526529808500 526529808500
result:
wrong answer 1st lines differ - expected: '8921593237533', found: '526529808500'