結果

問題 No.800 四平方定理
ユーザー ngtkanangtkana
提出日時 2020-03-30 22:29:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 200,476 KB
実行使用メモリ 65,684 KB
最終ジャッジ日時 2023-09-05 09:32:02
合計ジャッジ時間 4,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 33 ms
34,000 KB
testcase_11 AC 38 ms
37,792 KB
testcase_12 AC 38 ms
37,336 KB
testcase_13 AC 34 ms
35,300 KB
testcase_14 AC 37 ms
37,860 KB
testcase_15 AC 38 ms
37,600 KB
testcase_16 AC 36 ms
38,136 KB
testcase_17 AC 36 ms
38,068 KB
testcase_18 AC 41 ms
38,116 KB
testcase_19 AC 43 ms
38,092 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 42 ms
38,184 KB
testcase_23 AC 81 ms
65,440 KB
testcase_24 AC 78 ms
65,456 KB
testcase_25 AC 81 ms
65,356 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 76 ms
65,148 KB
testcase_29 AC 80 ms
65,328 KB
testcase_30 AC 75 ms
65,212 KB
testcase_31 AC 67 ms
60,864 KB
testcase_32 AC 75 ms
65,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,d;std::cin>>n>>d;
    lint N=2*n*n;
    std::vector<lint>a(N+1);
    for(lint i=1;i<=n;i++)for(lint j=1;j<=n;j++){
        a.at(i*i+j*j)++;
    }
    lint ans=0;
    for(lint i=1;i<=n;i++)for(lint j=1;j<=n;j++){
        lint x=d+i*i-j*j;
        if(0<=x&&x<=N)ans+=a.at(x);
    }
    std::cout<<ans<<'\n';
}

0