結果

問題 No.781 円周上の格子点の数え上げ
ユーザー merom686merom686
提出日時 2019-01-11 22:29:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,179 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 73,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 11:34:34
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 85 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 69 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 70 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int p[100] = { 72,96,96,96,96,96,96,96,128,96,128,128,108,128,128,96,128,128,96,128,144,128,128,128,128,128,144,144,128,144,128,128,128,128,144,128,128,128,144,128,160,144,128,144,128,144,144,128,128,144,144,160,144,144,144,128,160,144,144,192,128,144,128,144,144,192,128,128,144,144,144,128,144,160,144,144,144,144,144,128,160,144,144,192,192,144,128,160,128,144,144,144,144,128,144,144,160,192,144,144, };
    
    int m = 0;
    for (int r = x; r <= y; r++) {
        if (r % 100000 == 1) {
            for (int i = r / 100000; i < y / 100000; i++) {
                m = max(m, p[i]);
            }
            r = y / 100000 * 100000 + 1;
        }
        int b = 0, c = 0;
        for (int a = (int)sqrt(r); b = (int)sqrt(r - a * a), a >= b; a--) {
            if (a * a + b * b == r) {
                c++;
                if (a > b && b != 0) c++;
            }
        }
        m = max(m, c * 4);
    }

    cout << m << endl;

    return 0;
}
0