結果

問題 No.781 円周上の格子点の数え上げ
ユーザー face4face4
提出日時 2019-01-11 21:50:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 67,488 KB
実行使用メモリ 42,684 KB
最終ジャッジ日時 2023-08-20 05:33:50
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
42,672 KB
testcase_01 AC 158 ms
42,468 KB
testcase_02 AC 159 ms
42,576 KB
testcase_03 AC 158 ms
42,600 KB
testcase_04 AC 156 ms
42,684 KB
testcase_05 AC 165 ms
42,380 KB
testcase_06 AC 164 ms
42,636 KB
testcase_07 AC 156 ms
42,460 KB
testcase_08 AC 161 ms
42,396 KB
testcase_09 AC 155 ms
42,452 KB
testcase_10 AC 158 ms
42,456 KB
testcase_11 AC 155 ms
42,600 KB
testcase_12 AC 163 ms
42,464 KB
testcase_13 AC 168 ms
42,448 KB
testcase_14 AC 156 ms
42,512 KB
testcase_15 AC 155 ms
42,476 KB
testcase_16 AC 172 ms
42,448 KB
testcase_17 AC 153 ms
42,416 KB
testcase_18 AC 150 ms
42,400 KB
testcase_19 AC 150 ms
42,516 KB
testcase_20 AC 154 ms
42,460 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