結果

問題 No.800 四平方定理
ユーザー pppppppoipoipppppppoipoi
提出日時 2019-04-16 22:56:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 518 bytes
コンパイル時間 1,349 ms
コンパイル使用メモリ 69,368 KB
実行使用メモリ 65,868 KB
最終ジャッジ日時 2023-10-22 07:14:32
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 4 ms
4,412 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,412 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,676 KB
testcase_07 RE -
testcase_08 AC 3 ms
4,676 KB
testcase_09 AC 4 ms
4,676 KB
testcase_10 AC 37 ms
34,416 KB
testcase_11 AC 41 ms
38,240 KB
testcase_12 AC 39 ms
37,448 KB
testcase_13 AC 36 ms
35,668 KB
testcase_14 AC 38 ms
38,240 KB
testcase_15 AC 41 ms
37,976 KB
testcase_16 AC 40 ms
38,504 KB
testcase_17 AC 40 ms
38,504 KB
testcase_18 AC 45 ms
38,504 KB
testcase_19 AC 44 ms
38,504 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 RE -
testcase_22 AC 43 ms
38,504 KB
testcase_23 AC 93 ms
65,868 KB
testcase_24 AC 91 ms
65,868 KB
testcase_25 AC 91 ms
65,604 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 RE -
testcase_28 AC 85 ms
65,604 KB
testcase_29 AC 96 ms
65,868 KB
testcase_30 AC 86 ms
65,604 KB
testcase_31 AC 77 ms
61,252 KB
testcase_32 AC 88 ms
65,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,d,ans = 0;
    cin >> n >> d;
    vector<int> a(2*n*n+10),b(2*n*n+10);
    
    for(int x = 1;x <= n;x++){
        for(int y = 1;y <= n;y++){
            a[x*x+y*y]++;
        }
    }
    
    for(int w = 1;w <= n;w++){
        for(int z = 1;z <= n;z++){
            if(w*w-z*z+d < 0) continue;
            b[w*w-z*z+d]++;
        }
    }
    for(int i = 0;i <= 2*n*n;i++){
        ans += a[i]*b[i];
    }
    cout << ans << endl;
}
0