結果

問題 No.781 円周上の格子点の数え上げ
ユーザー face4face4
提出日時 2019-01-11 21:50:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 68,224 KB
実行使用メモリ 42,496 KB
最終ジャッジ日時 2024-05-07 12:54:49
合計ジャッジ時間 4,231 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
42,496 KB
testcase_01 AC 135 ms
42,496 KB
testcase_02 AC 137 ms
42,368 KB
testcase_03 AC 147 ms
42,496 KB
testcase_04 AC 144 ms
42,368 KB
testcase_05 AC 145 ms
42,368 KB
testcase_06 AC 141 ms
42,496 KB
testcase_07 AC 135 ms
42,496 KB
testcase_08 AC 135 ms
42,496 KB
testcase_09 AC 139 ms
42,496 KB
testcase_10 AC 137 ms
42,496 KB
testcase_11 AC 135 ms
42,368 KB
testcase_12 AC 140 ms
42,368 KB
testcase_13 AC 148 ms
42,368 KB
testcase_14 AC 137 ms
42,496 KB
testcase_15 AC 136 ms
42,496 KB
testcase_16 AC 136 ms
42,496 KB
testcase_17 AC 148 ms
42,368 KB
testcase_18 AC 135 ms
42,496 KB
testcase_19 AC 143 ms
42,496 KB
testcase_20 AC 135 ms
42,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;

int memo[10000000] = {};

int main(){
    int x, y;
    cin >> x >> y;

    int tmp = sqrt(10000000);
    for(int i = 0; i <= tmp; i++){
        for(int j = 0; j <= tmp; j++){
            if(i*i+j*j > 10000000)  break;
            memo[i*i+j*j] += 4;
            if(i == 0 || j == 0)    memo[i*i+j*j] -= 2;
        }
    }

    int ans = 0;
    for(int i = x; i <= y; i++){
        ans = max(ans, memo[i]);
    }

    cout << ans << endl;

    return 0;
}
0