結果

問題 No.800 四平方定理
ユーザー pianonekopianoneko
提出日時 2019-03-18 12:57:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 167,484 KB
実行使用メモリ 36,388 KB
最終ジャッジ日時 2023-09-25 08:21:32
合計ジャッジ時間 3,648 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 21 ms
19,780 KB
testcase_11 AC 23 ms
21,816 KB
testcase_12 AC 24 ms
21,772 KB
testcase_13 AC 23 ms
19,724 KB
testcase_14 AC 25 ms
21,816 KB
testcase_15 AC 25 ms
21,744 KB
testcase_16 AC 26 ms
21,744 KB
testcase_17 AC 25 ms
21,768 KB
testcase_18 AC 30 ms
21,860 KB
testcase_19 AC 30 ms
21,740 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 30 ms
21,836 KB
testcase_23 AC 71 ms
36,388 KB
testcase_24 AC 60 ms
36,156 KB
testcase_25 AC 64 ms
36,088 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 58 ms
36,152 KB
testcase_29 AC 64 ms
36,376 KB
testcase_30 AC 57 ms
36,108 KB
testcase_31 AC 51 ms
34,148 KB
testcase_32 AC 57 ms
36,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int cnt[10000000];

int main() {
    int N, D;
    cin >> N >> D;
    map<int, int> mp;
    for(int x = 1; x < N + 1; x++) {
        for(int y = 1; y < N + 1; y++) {
            cnt[(int)(pow(x, 2) + pow(y, 2))] += 1;
        }
    }
    long long ans = 0;
    for(int w = 1; w < N + 1; w++) {
        for(int z = 1; z < N + 1; z++) {
            if (pow(w, 2) + D - pow(z, 2) <= 0) continue;
            ans += cnt[(int)(pow(w, 2) + D - pow(z, 2))];
        }
    }
    cout << ans << endl;
}
0