結果

問題 No.781 円周上の格子点の数え上げ
ユーザー MisterMister
提出日時 2020-04-18 01:19:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 42,396 KB
最終ジャッジ日時 2024-04-14 18:47:15
合計ジャッジ時間 8,184 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
42,348 KB
testcase_01 AC 293 ms
42,324 KB
testcase_02 AC 292 ms
42,356 KB
testcase_03 AC 292 ms
42,216 KB
testcase_04 AC 291 ms
42,264 KB
testcase_05 AC 294 ms
42,264 KB
testcase_06 AC 290 ms
42,328 KB
testcase_07 AC 292 ms
42,264 KB
testcase_08 AC 287 ms
42,396 KB
testcase_09 AC 290 ms
42,328 KB
testcase_10 AC 290 ms
42,328 KB
testcase_11 AC 287 ms
42,148 KB
testcase_12 AC 298 ms
42,244 KB
testcase_13 AC 295 ms
42,236 KB
testcase_14 AC 288 ms
42,216 KB
testcase_15 AC 296 ms
42,216 KB
testcase_16 AC 294 ms
42,384 KB
testcase_17 AC 297 ms
42,296 KB
testcase_18 AC 288 ms
42,324 KB
testcase_19 AC 287 ms
42,284 KB
testcase_20 AC 287 ms
42,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

constexpr int X = 4000;
constexpr int R = 10000000;

int dist(int x, int y) {
    return x * x + y * y;
}

void solve() {
    std::vector<int> cnt(R + 1, 0);
    for (int x = -X; x <= X; ++x) {
        for (int y = -X; y <= X; ++y) {
            int d = dist(x, y);
            if (d <= R) ++cnt[d];
        }
    }

    int x, y;
    std::cin >> x >> y;
    std::cout << *std::max_element(cnt.begin() + x, cnt.begin() + y + 1)
              << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0