結果

問題 No.800 四平方定理
ユーザー SuikabaSuikaba
提出日時 2019-03-17 21:32:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 198,788 KB
実行使用メモリ 107,976 KB
最終ジャッジ日時 2023-09-22 04:02:15
合計ジャッジ時間 4,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,696 KB
testcase_01 AC 13 ms
6,004 KB
testcase_02 AC 13 ms
5,804 KB
testcase_03 AC 12 ms
5,864 KB
testcase_04 AC 13 ms
6,068 KB
testcase_05 AC 13 ms
5,888 KB
testcase_06 AC 13 ms
6,128 KB
testcase_07 AC 13 ms
6,596 KB
testcase_08 AC 14 ms
8,076 KB
testcase_09 AC 12 ms
6,040 KB
testcase_10 AC 59 ms
56,624 KB
testcase_11 AC 62 ms
58,612 KB
testcase_12 AC 66 ms
60,660 KB
testcase_13 AC 53 ms
52,484 KB
testcase_14 AC 58 ms
56,836 KB
testcase_15 AC 64 ms
60,936 KB
testcase_16 AC 59 ms
58,656 KB
testcase_17 AC 60 ms
58,616 KB
testcase_18 AC 72 ms
66,812 KB
testcase_19 AC 73 ms
66,816 KB
testcase_20 AC 13 ms
5,380 KB
testcase_21 AC 13 ms
5,376 KB
testcase_22 AC 72 ms
66,808 KB
testcase_23 AC 117 ms
107,932 KB
testcase_24 AC 106 ms
99,744 KB
testcase_25 AC 120 ms
107,976 KB
testcase_26 AC 13 ms
5,492 KB
testcase_27 AC 13 ms
7,476 KB
testcase_28 AC 104 ms
99,576 KB
testcase_29 AC 111 ms
103,940 KB
testcase_30 AC 104 ms
99,736 KB
testcase_31 AC 110 ms
93,492 KB
testcase_32 AC 106 ms
99,624 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