結果

問題 No.800 四平方定理
ユーザー SuikabaSuikaba
提出日時 2019-03-17 21:32:10
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,692 ms
使用メモリ 103,584 KB
最終ジャッジ日時 2023-02-11 04:32:15
合計ジャッジ時間 4,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 8 ms
6,952 KB
testcase_01 AC 8 ms
6,948 KB
testcase_02 AC 8 ms
6,016 KB
testcase_03 AC 8 ms
6,948 KB
testcase_04 AC 7 ms
5,992 KB
testcase_05 AC 8 ms
6,040 KB
testcase_06 AC 9 ms
6,948 KB
testcase_07 AC 8 ms
6,604 KB
testcase_08 AC 8 ms
8,176 KB
testcase_09 AC 8 ms
6,952 KB
testcase_10 AC 36 ms
52,688 KB
testcase_11 AC 38 ms
56,580 KB
testcase_12 AC 42 ms
58,156 KB
testcase_13 AC 31 ms
51,220 KB
testcase_14 AC 35 ms
54,732 KB
testcase_15 AC 39 ms
58,520 KB
testcase_16 AC 36 ms
55,380 KB
testcase_17 AC 36 ms
55,336 KB
testcase_18 AC 46 ms
62,900 KB
testcase_19 AC 45 ms
63,068 KB
testcase_20 AC 8 ms
5,600 KB
testcase_21 AC 8 ms
5,456 KB
testcase_22 AC 47 ms
63,088 KB
testcase_23 AC 107 ms
103,584 KB
testcase_24 AC 91 ms
95,756 KB
testcase_25 AC 109 ms
103,268 KB
testcase_26 AC 8 ms
5,596 KB
testcase_27 AC 8 ms
7,624 KB
testcase_28 AC 91 ms
95,204 KB
testcase_29 AC 100 ms
99,524 KB
testcase_30 AC 95 ms
95,276 KB
testcase_31 AC 84 ms
88,844 KB
testcase_32 AC 94 ms
96,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll l[1 << 23], r[1 << 23];

int main() {
    int n, d; cin >> n >> d;
    for(int a = 1; a <= n; ++a) {
        for(int b = 1; b <= n; ++b) {
            l[a * a + b * b] += 1;
            if(a * a - b * b + d >= 0) {
                r[a * a - b * b + d] += 1;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 1 << 23; ++i) {
        ans += l[i] * r[i];
    }
    
    cout << ans << endl;
}
0