結果

問題 No.800 四平方定理
ユーザー Y17Y17
提出日時 2019-03-17 22:48:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 144,036 KB
実行使用メモリ 23,816 KB
最終ジャッジ日時 2023-09-22 09:01:14
合計ジャッジ時間 3,167 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 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,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 16 ms
13,536 KB
testcase_11 AC 17 ms
13,812 KB
testcase_12 AC 21 ms
15,692 KB
testcase_13 AC 14 ms
11,492 KB
testcase_14 AC 17 ms
13,684 KB
testcase_15 AC 17 ms
15,600 KB
testcase_16 AC 16 ms
13,644 KB
testcase_17 AC 15 ms
13,708 KB
testcase_18 AC 25 ms
17,668 KB
testcase_19 AC 23 ms
17,904 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 20 ms
17,868 KB
testcase_23 AC 48 ms
23,780 KB
testcase_24 AC 38 ms
19,688 KB
testcase_25 AC 45 ms
23,816 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 41 ms
19,832 KB
testcase_29 AC 44 ms
21,752 KB
testcase_30 AC 41 ms
19,712 KB
testcase_31 AC 38 ms
19,776 KB
testcase_32 AC 42 ms
19,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int mp[8000010] = {};

int main(){
    int n, d;
    cin >> n >> d;

    int ans = 0;

    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(i*i-j*j+d > 0 && i*i-j*j+d <= n*n+n*n){
                mp[i*i-j*j+d]++;
            }
        }
    }

    for(long long i = 1;i <= n;i++){
        for(long long j = 1;j <= n;j++){
            if(i*i+j*j > 0){
                ans += mp[i*i+j*j];
            }
        }
    }


    cout << ans << endl;

    return 0;
}



0