結果

問題 No.781 円周上の格子点の数え上げ
ユーザー finefine
提出日時 2019-01-11 21:49:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 1,671 ms
コンパイル使用メモリ 163,228 KB
実行使用メモリ 81,608 KB
最終ジャッジ日時 2023-08-20 05:30:24
合計ジャッジ時間 5,759 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
81,508 KB
testcase_01 AC 137 ms
81,452 KB
testcase_02 AC 139 ms
81,508 KB
testcase_03 AC 137 ms
81,452 KB
testcase_04 AC 137 ms
81,544 KB
testcase_05 AC 136 ms
81,452 KB
testcase_06 AC 139 ms
81,504 KB
testcase_07 AC 139 ms
81,492 KB
testcase_08 AC 139 ms
81,452 KB
testcase_09 AC 137 ms
81,436 KB
testcase_10 AC 142 ms
81,464 KB
testcase_11 AC 138 ms
81,456 KB
testcase_12 AC 142 ms
81,608 KB
testcase_13 AC 149 ms
81,492 KB
testcase_14 AC 138 ms
81,508 KB
testcase_15 AC 137 ms
81,488 KB
testcase_16 AC 138 ms
81,540 KB
testcase_17 AC 144 ms
81,508 KB
testcase_18 AC 139 ms
81,464 KB
testcase_19 AC 138 ms
81,496 KB
testcase_20 AC 140 ms
81,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MAXV = 10000000;
ll cnt[MAXV + 1];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i * i <= MAXV; i++) {
        for (int j = 0; j <= i; j++) {
            int sum = i * i + j * j;
            if (sum > MAXV) break;
            int add = (1 + (i != 0)) * (1 + (j != 0));
            if (i != j) add *= 2;
            cnt[sum] += add;
        }
    }

    int x, y;
    cin >> x >> y;
    ll ans = 0;
    for (int i = x; i <= y; i++) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
    return 0;
}
0