結果

問題 No.800 四平方定理
ユーザー tadanoningentadanoningen
提出日時 2021-03-14 11:41:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,914 ms
コンパイル使用メモリ 193,404 KB
実行使用メモリ 64,640 KB
最終ジャッジ日時 2024-04-23 19:32:27
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 40 ms
33,664 KB
testcase_11 AC 53 ms
37,632 KB
testcase_12 AC 52 ms
36,864 KB
testcase_13 AC 47 ms
35,200 KB
testcase_14 AC 51 ms
37,504 KB
testcase_15 AC 54 ms
37,248 KB
testcase_16 AC 53 ms
37,760 KB
testcase_17 AC 55 ms
37,888 KB
testcase_18 AC 58 ms
37,760 KB
testcase_19 AC 59 ms
37,760 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 60 ms
37,888 KB
testcase_23 AC 124 ms
64,512 KB
testcase_24 AC 111 ms
64,512 KB
testcase_25 AC 126 ms
64,256 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 113 ms
64,128 KB
testcase_29 AC 122 ms
64,384 KB
testcase_30 AC 110 ms
64,512 KB
testcase_31 AC 102 ms
60,032 KB
testcase_32 AC 116 ms
64,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll xy[2001*4001];

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

    for(ll x=1;x <= n;x++){
        for(ll y=1;y <= n;y++){
            xy[x*x + y*y]++;
        }
    }

    ll ans = 0;

    for(ll w=1;w <= n;w++){
        for(ll z=1;z <= n;z++){
            ll X = w*w - z*z + d;
            if(X >= 0) ans += xy[X];
        }
    }

    cout << ans << endl;
    return 0;
}
0