結果

問題 No.781 円周上の格子点の数え上げ
ユーザー Mister
提出日時 2020-04-18 01:19:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 74,880 KB
最終ジャッジ日時 2025-01-09 21:01:50
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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