結果

問題 No.800 四平方定理
ユーザー xuzijian629xuzijian629
提出日時 2019-03-17 21:45:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 484 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 202,652 KB
実行使用メモリ 50,000 KB
最終ジャッジ日時 2023-09-22 04:51:27
合計ジャッジ時間 30,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 13 ms
4,404 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 912 ms
26,496 KB
testcase_11 AC 1,012 ms
29,076 KB
testcase_12 AC 1,009 ms
28,472 KB
testcase_13 AC 963 ms
27,548 KB
testcase_14 AC 1,040 ms
29,004 KB
testcase_15 AC 1,010 ms
28,732 KB
testcase_16 AC 1,029 ms
29,124 KB
testcase_17 AC 1,000 ms
29,328 KB
testcase_18 AC 1,006 ms
28,868 KB
testcase_19 AC 965 ms
29,064 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1,010 ms
29,280 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 AC 1,993 ms
49,936 KB
testcase_31 AC 1,795 ms
47,616 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, d;
    cin >> n >> d;
    unordered_map<int, int> cnt;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cnt[i * i + j * j]++;
        }
    }

    int ans = 0;
    for (int w = 1; w <= n; w++) {
        int r = w * w + d;
        for (int z = 1; z <= n; z++) {
            if (cnt.count(r - z * z))
            ans += cnt[r - z * z];
        }
    }
    cout << ans << endl;
}
0