結果

問題 No.800 四平方定理
ユーザー betrue12betrue12
提出日時 2019-03-17 21:31:31
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 1,910 ms
使用メモリ 65,440 KB
最終ジャッジ日時 2023-02-11 04:29:03
合計ジャッジ時間 4,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 11 ms
5,800 KB
testcase_01 AC 11 ms
6,072 KB
testcase_02 AC 10 ms
6,948 KB
testcase_03 AC 10 ms
6,952 KB
testcase_04 AC 11 ms
5,800 KB
testcase_05 AC 10 ms
6,952 KB
testcase_06 AC 11 ms
6,248 KB
testcase_07 AC 11 ms
6,948 KB
testcase_08 AC 10 ms
6,948 KB
testcase_09 AC 11 ms
6,132 KB
testcase_10 AC 32 ms
34,728 KB
testcase_11 AC 33 ms
38,452 KB
testcase_12 AC 32 ms
37,392 KB
testcase_13 AC 31 ms
35,648 KB
testcase_14 AC 33 ms
37,984 KB
testcase_15 AC 32 ms
38,304 KB
testcase_16 AC 33 ms
38,296 KB
testcase_17 AC 32 ms
38,756 KB
testcase_18 AC 33 ms
38,168 KB
testcase_19 AC 33 ms
38,196 KB
testcase_20 AC 10 ms
6,956 KB
testcase_21 AC 10 ms
5,576 KB
testcase_22 AC 33 ms
38,920 KB
testcase_23 AC 76 ms
65,436 KB
testcase_24 AC 75 ms
65,440 KB
testcase_25 AC 76 ms
65,268 KB
testcase_26 AC 11 ms
5,524 KB
testcase_27 AC 11 ms
6,948 KB
testcase_28 AC 74 ms
65,060 KB
testcase_29 AC 77 ms
65,288 KB
testcase_30 AC 73 ms
65,112 KB
testcase_31 AC 66 ms
60,752 KB
testcase_32 AC 75 ms
65,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int N, D;
    cin >> N >> D;
    const int M = 2000*2000*2+1;
    int offset = 2000*2000;
    static int mp1[M], mp2[M];
    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++){
        mp1[i*i+j*j]++;
        mp2[i*i-j*j+offset]++;
    }

    int64_t ans = 0;
    for(int i=0; i<M; i++){
        int Y = D - i + offset;
        if(0<=Y && Y<M) ans += mp1[i] * mp2[Y];
    }
    cout << ans << endl;
    return 0;
}
0