結果

問題 No.800 四平方定理
ユーザー recososorecososo
提出日時 2020-02-25 17:54:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 163,708 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-04-21 13:53:17
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 27 ms
18,688 KB
testcase_11 AC 30 ms
20,656 KB
testcase_12 AC 31 ms
20,352 KB
testcase_13 AC 27 ms
19,560 KB
testcase_14 AC 30 ms
20,588 KB
testcase_15 AC 30 ms
20,608 KB
testcase_16 AC 29 ms
20,864 KB
testcase_17 AC 29 ms
20,816 KB
testcase_18 AC 30 ms
20,768 KB
testcase_19 AC 31 ms
20,704 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 33 ms
20,736 KB
testcase_23 AC 80 ms
34,432 KB
testcase_24 AC 72 ms
34,432 KB
testcase_25 AC 80 ms
34,508 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 73 ms
34,304 KB
testcase_29 AC 84 ms
34,560 KB
testcase_30 AC 75 ms
34,304 KB
testcase_31 AC 65 ms
32,256 KB
testcase_32 AC 76 ms
34,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;cin >> n >> d;
    vector<int> p(n*n*2+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            p[i*i+j*j]++;
        }
    }
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(d+j*j-i*i>=0&&d+j*j-i*i<=n*n*2+1){
                ans+=p[d+j*j-i*i];
            }
        }
    }
    cout << ans << endl;
}
0