結果

問題 No.800 四平方定理
ユーザー cherrypi59cherrypi59
提出日時 2019-04-20 13:48:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 166,884 KB
実行使用メモリ 57,440 KB
最終ジャッジ日時 2024-04-08 13:56:03
合計ジャッジ時間 3,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,748 KB
testcase_01 AC 3 ms
7,888 KB
testcase_02 AC 3 ms
7,752 KB
testcase_03 AC 3 ms
7,752 KB
testcase_04 AC 3 ms
7,776 KB
testcase_05 AC 3 ms
7,780 KB
testcase_06 AC 3 ms
7,876 KB
testcase_07 AC 4 ms
8,148 KB
testcase_08 AC 4 ms
9,668 KB
testcase_09 AC 4 ms
7,876 KB
testcase_10 AC 30 ms
32,864 KB
testcase_11 AC 33 ms
34,912 KB
testcase_12 AC 37 ms
34,912 KB
testcase_13 AC 29 ms
30,816 KB
testcase_14 AC 31 ms
32,864 KB
testcase_15 AC 36 ms
34,912 KB
testcase_16 AC 31 ms
32,864 KB
testcase_17 AC 31 ms
32,864 KB
testcase_18 AC 36 ms
36,960 KB
testcase_19 AC 37 ms
36,960 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 39 ms
36,960 KB
testcase_23 AC 75 ms
57,440 KB
testcase_24 AC 66 ms
53,344 KB
testcase_25 AC 74 ms
57,440 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 3 ms
7,620 KB
testcase_28 AC 65 ms
53,344 KB
testcase_29 AC 71 ms
55,392 KB
testcase_30 AC 69 ms
53,344 KB
testcase_31 AC 62 ms
51,296 KB
testcase_32 AC 70 ms
53,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAX_D = (int)8e6 + 5;
int A[MAX_D], B[MAX_D];

int main(){
    int N, D; cin >> N >> D;

    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            A[i*i+j*j]++;
            if(0<i*i-j*j+D) B[i*i-j*j+D]++;
        }
    }

    int ans = 0;
    for(int i=1;i<=2*N*N;i++) ans += A[i] * B[i];

    cout << ans << endl;
    return 0;
}
0