結果

問題 No.781 円周上の格子点の数え上げ
ユーザー finefine
提出日時 2019-01-11 21:49:15
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 1,280 ms
使用メモリ 81,636 KB
最終ジャッジ日時 2023-01-06 10:53:44
合計ジャッジ時間 4,876 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 89 ms
81,540 KB
testcase_01 AC 88 ms
81,556 KB
testcase_02 AC 89 ms
81,572 KB
testcase_03 AC 90 ms
81,580 KB
testcase_04 AC 89 ms
81,576 KB
testcase_05 AC 88 ms
81,504 KB
testcase_06 AC 87 ms
81,524 KB
testcase_07 AC 89 ms
81,572 KB
testcase_08 AC 90 ms
81,496 KB
testcase_09 AC 87 ms
81,568 KB
testcase_10 AC 89 ms
81,504 KB
testcase_11 AC 88 ms
81,504 KB
testcase_12 AC 92 ms
81,624 KB
testcase_13 AC 97 ms
81,620 KB
testcase_14 AC 87 ms
81,636 KB
testcase_15 AC 87 ms
81,512 KB
testcase_16 AC 88 ms
81,508 KB
testcase_17 AC 94 ms
81,508 KB
testcase_18 AC 86 ms
81,568 KB
testcase_19 AC 89 ms
81,504 KB
testcase_20 AC 89 ms
81,608 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