結果

問題 No.781 円周上の格子点の数え上げ
ユーザー hedwig100hedwig100
提出日時 2020-04-13 14:37:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 171,020 KB
実行使用メモリ 42,452 KB
最終ジャッジ日時 2023-10-25 03:42:06
合計ジャッジ時間 2,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 19 ms
42,452 KB
testcase_09 AC 19 ms
42,452 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 78 ms
42,452 KB
testcase_13 AC 141 ms
42,452 KB
testcase_14 AC 4 ms
5,396 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 72 ms
26,364 KB
testcase_18 AC 13 ms
26,364 KB
testcase_19 AC 13 ms
27,156 KB
testcase_20 AC 14 ms
27,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

int main() {
    int x,y; cin >> x >> y;
    vector<int> square;
    for (int i = 0;i * i <= y; i++) {
        square.push_back(i * i);
    }

    vector<int> cnt(y + 1,0);
    for (int p1:square) {
        for (int p2:square) {
            if (p1 + p2 < x || p1 + p2 > y) continue;
            if (p1 == 0 || p2 == 0) cnt[p1 + p2] += 2;
            else cnt[p1 + p2] += 4;
        }       
    }
    
    int ans = 0;
    for (int i = x; i < y + 1; i ++) {
        ans = max(ans,cnt[i]);
    }
    cout << ans << endl;
    return 0;
}
0