QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178364#5503. Euclidean Algorithmreal_sigma_team#TL 0ms3380kbC++20673b2023-09-13 21:42:342023-09-13 21:42:35

Judging History

你现在查看的是最新测评结果

  • [2023-09-13 21:42:35]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3380kb
  • [2023-09-13 21:42:34]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using ll = long long;

const int N = 3e5 + 5;

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll x = 1; x <= n; ++x) {
        for (ll y = x + 1; y <= n; ++y) {
            if ((y - gcd(x, y)) % (y - x) == 0) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
#endif
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3380kb

input:

3
2
5
14

output:

1
9
62

result:

ok 3 lines

Test #2:

score: -100
Time Limit Exceeded

input:

3
29107867360
65171672278
41641960535

output:


result: