結果

問題 No.781 円周上の格子点の数え上げ
ユーザー face4face4
提出日時 2019-01-11 21:50:40
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 423 ms
使用メモリ 42,552 KB
最終ジャッジ日時 2023-01-06 10:57:50
合計ジャッジ時間 4,691 ms
ジャッジサーバーID
(参考情報)
judge16 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 141 ms
42,376 KB
testcase_01 AC 141 ms
42,404 KB
testcase_02 AC 140 ms
42,460 KB
testcase_03 AC 139 ms
42,460 KB
testcase_04 AC 140 ms
42,440 KB
testcase_05 AC 143 ms
42,400 KB
testcase_06 AC 140 ms
42,552 KB
testcase_07 AC 139 ms
42,472 KB
testcase_08 AC 140 ms
42,472 KB
testcase_09 AC 140 ms
42,396 KB
testcase_10 AC 140 ms
42,444 KB
testcase_11 AC 141 ms
42,376 KB
testcase_12 AC 148 ms
42,532 KB
testcase_13 AC 149 ms
42,440 KB
testcase_14 AC 142 ms
42,496 KB
testcase_15 AC 138 ms
42,524 KB
testcase_16 AC 141 ms
42,496 KB
testcase_17 AC 147 ms
42,384 KB
testcase_18 AC 141 ms
42,440 KB
testcase_19 AC 142 ms
42,396 KB
testcase_20 AC 140 ms
42,500 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