結果

問題 No.800 四平方定理
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-03-19 10:53:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 73,364 KB
実行使用メモリ 34,336 KB
最終ジャッジ日時 2023-10-11 15:41:54
合計ジャッジ時間 3,531 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 23 ms
18,600 KB
testcase_11 AC 25 ms
20,508 KB
testcase_12 AC 24 ms
19,964 KB
testcase_13 AC 20 ms
19,128 KB
testcase_14 AC 23 ms
20,500 KB
testcase_15 AC 24 ms
20,228 KB
testcase_16 AC 24 ms
20,512 KB
testcase_17 AC 23 ms
20,848 KB
testcase_18 AC 26 ms
20,428 KB
testcase_19 AC 25 ms
20,516 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 27 ms
20,584 KB
testcase_23 AC 63 ms
34,304 KB
testcase_24 AC 56 ms
34,272 KB
testcase_25 AC 65 ms
34,236 KB
testcase_26 AC 2 ms
4,356 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 60 ms
34,320 KB
testcase_29 AC 62 ms
34,156 KB
testcase_30 AC 58 ms
34,336 KB
testcase_31 AC 51 ms
32,036 KB
testcase_32 AC 61 ms
34,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

int main(int argc, char const *argv[]) {
    // x^2 + y^2 = D+ w^2 - z^2
    int n, d;
    std::cin >> n >> d;

    std::vector<int> c(n * n * 2 + 1, 0);
    for (int x = 1; x <= n; x++) {
        for (int y = 1; y <= n; y++) {
            c[x * x + y * y]++;
        }
    }

    int ans = 0;
    for (int w = 1; w <= n; w++) {
        for (int z = 1; z <= n; z++) {
            int k = d + w * w - z * z;
            if (0 <= k && k < c.size()) ans += c[k];
        }
    }
    
    std::cout << ans << std::endl;
    return 0;
}
0