結果

問題 No.800 四平方定理
ユーザー hiro71687khiro71687k
提出日時 2023-03-15 14:53:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 4,242 ms
コンパイル使用メモリ 262,272 KB
実行使用メモリ 69,632 KB
最終ジャッジ日時 2023-10-18 12:23:57
合計ジャッジ時間 6,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,352 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,352 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,352 KB
testcase_06 AC 4 ms
4,616 KB
testcase_07 AC 3 ms
4,880 KB
testcase_08 AC 4 ms
5,672 KB
testcase_09 AC 3 ms
4,616 KB
testcase_10 AC 34 ms
36,136 KB
testcase_11 AC 40 ms
38,972 KB
testcase_12 AC 41 ms
39,696 KB
testcase_13 AC 35 ms
35,608 KB
testcase_14 AC 39 ms
38,180 KB
testcase_15 AC 43 ms
39,960 KB
testcase_16 AC 40 ms
38,444 KB
testcase_17 AC 39 ms
38,444 KB
testcase_18 AC 44 ms
42,268 KB
testcase_19 AC 47 ms
42,268 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 44 ms
42,304 KB
testcase_23 AC 96 ms
69,632 KB
testcase_24 AC 91 ms
65,808 KB
testcase_25 AC 97 ms
69,632 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 4 ms
7,188 KB
testcase_28 AC 86 ms
65,544 KB
testcase_29 AC 91 ms
67,588 KB
testcase_30 AC 90 ms
65,544 KB
testcase_31 AC 78 ms
61,192 KB
testcase_32 AC 91 ms
66,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.141592653589793;
ll inf=444444444;
ll mod=1000000007;
int main(){
    ll n,d;
    cin >> n >> d;
    vector<ll>memo(n*n+n*n+2,0);
    for (ll i = 1; i <=n; i++)
    {
        for (ll j = 1; j <=n; j++)
        {
            memo[i*i+j*j]+=1;
        }
    }
    vector<ll>memo2(n*n+n*n+2+d,0);
    for (ll i = 1; i <=n; i++)
    {
        for (ll j = 1; j <=n; j++)
        {
            if (i*i-j*j+d<=0)
            {
                continue;
            }
            memo2[i*i-j*j+d]+=1;
        }
    }
    ll ans=0;
    for (ll i = 1; i < memo.size(); i++)
    {
        ans+=memo[i]*memo2[i];
    }
    cout << ans << endl;
}
0