結果

問題 No.800 四平方定理
ユーザー betrue12betrue12
提出日時 2019-03-17 21:31:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 198,272 KB
実行使用メモリ 65,420 KB
最終ジャッジ日時 2023-09-22 03:59:33
合計ジャッジ時間 4,642 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,604 KB
testcase_01 AC 12 ms
7,452 KB
testcase_02 AC 12 ms
7,532 KB
testcase_03 AC 11 ms
7,528 KB
testcase_04 AC 11 ms
7,424 KB
testcase_05 AC 11 ms
7,460 KB
testcase_06 AC 12 ms
7,400 KB
testcase_07 AC 11 ms
7,528 KB
testcase_08 AC 12 ms
7,428 KB
testcase_09 AC 11 ms
7,460 KB
testcase_10 AC 53 ms
38,312 KB
testcase_11 AC 56 ms
40,216 KB
testcase_12 AC 55 ms
40,168 KB
testcase_13 AC 54 ms
40,308 KB
testcase_14 AC 56 ms
40,164 KB
testcase_15 AC 57 ms
40,164 KB
testcase_16 AC 59 ms
40,216 KB
testcase_17 AC 56 ms
40,172 KB
testcase_18 AC 60 ms
40,188 KB
testcase_19 AC 58 ms
40,196 KB
testcase_20 AC 11 ms
7,424 KB
testcase_21 AC 11 ms
7,588 KB
testcase_22 AC 58 ms
40,168 KB
testcase_23 AC 104 ms
65,256 KB
testcase_24 AC 105 ms
65,236 KB
testcase_25 AC 102 ms
65,116 KB
testcase_26 AC 12 ms
7,716 KB
testcase_27 AC 11 ms
7,668 KB
testcase_28 AC 107 ms
65,088 KB
testcase_29 AC 108 ms
65,216 KB
testcase_30 AC 108 ms
65,144 KB
testcase_31 AC 96 ms
63,596 KB
testcase_32 AC 104 ms
65,420 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