結果

問題 No.800 四平方定理
ユーザー rpy3cpprpy3cpp
提出日時 2019-05-01 23:08:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 166,168 KB
実行使用メモリ 38,080 KB
最終ジャッジ日時 2023-08-30 04:29:53
合計ジャッジ時間 3,632 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,912 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 20 ms
20,244 KB
testcase_11 AC 18 ms
21,496 KB
testcase_12 AC 19 ms
22,180 KB
testcase_13 AC 16 ms
19,216 KB
testcase_14 AC 17 ms
20,536 KB
testcase_15 AC 18 ms
22,480 KB
testcase_16 AC 18 ms
20,796 KB
testcase_17 AC 18 ms
20,664 KB
testcase_18 AC 23 ms
24,296 KB
testcase_19 AC 24 ms
24,556 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 23 ms
24,500 KB
testcase_23 AC 47 ms
38,080 KB
testcase_24 AC 40 ms
34,256 KB
testcase_25 AC 48 ms
38,068 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 4 ms
7,016 KB
testcase_28 AC 39 ms
33,984 KB
testcase_29 AC 42 ms
36,168 KB
testcase_30 AC 40 ms
34,304 KB
testcase_31 AC 36 ms
31,984 KB
testcase_32 AC 41 ms
34,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D;
    cin >> N >> D;
    vector<int> freq(2 * N * N + 1 + D, 0);
    for (int x = 1; x <= N; ++x){
        ++freq[x*x*2];
        for (int y = x + 1; y <= N; ++y){
            freq[x*x + y*y] += 2;
        }
    }
    long long ans = 0;
    for (int w = 1; w <= N; ++w){
        int wd = w * w + D;
        for (int z = 1; z <= N; ++z){
            int tmp = wd - z * z;
            if (tmp < 0) break;
            ans += freq[tmp];
        }
    }
    cout << ans << endl;
    return 0;
}

0