結果

問題 No.800 四平方定理
ユーザー zero_kprzero_kpr
提出日時 2019-03-18 00:28:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 167,496 KB
実行使用メモリ 128,208 KB
最終ジャッジ日時 2023-09-22 16:14:58
合計ジャッジ時間 4,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 4 ms
5,440 KB
testcase_02 AC 3 ms
4,568 KB
testcase_03 AC 4 ms
4,832 KB
testcase_04 AC 3 ms
4,644 KB
testcase_05 AC 4 ms
4,880 KB
testcase_06 AC 4 ms
6,056 KB
testcase_07 AC 4 ms
5,164 KB
testcase_08 AC 4 ms
5,964 KB
testcase_09 AC 4 ms
5,536 KB
testcase_10 AC 59 ms
65,260 KB
testcase_11 AC 62 ms
72,660 KB
testcase_12 AC 65 ms
71,356 KB
testcase_13 AC 55 ms
67,744 KB
testcase_14 AC 61 ms
72,660 KB
testcase_15 AC 65 ms
72,128 KB
testcase_16 AC 62 ms
73,380 KB
testcase_17 AC 61 ms
73,500 KB
testcase_18 AC 72 ms
73,000 KB
testcase_19 AC 71 ms
73,152 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 72 ms
73,588 KB
testcase_23 AC 138 ms
128,120 KB
testcase_24 AC 124 ms
128,208 KB
testcase_25 AC 138 ms
127,596 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 122 ms
127,320 KB
testcase_29 AC 129 ms
127,848 KB
testcase_30 AC 121 ms
127,684 KB
testcase_31 AC 113 ms
118,948 KB
testcase_32 AC 125 ms
128,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N,D; cin >> N >> D;
    vector<ll> cnt1(2*N*N + 1),cnt2(2*N*N + 1);
    for(int x = 1; x < N + 1; x++)
    {
        for(int y = 1; y < N + 1; y++)
        {
            cnt1.at(x*x + y*y)++;
        }
    }
    for(int w = 1; w <= N; w++)
    {
        for(int z = 1; z <= N; z++)
        {
            if(w*w + D - z*z >= 0 && w*w + D - z*z <= 2*N*N)
            {
                cnt2.at(w*w + D - z*z)++;
        }   }
    }
    int ans = 0;
    for(int i = 1; i < 2*N*N + 1; i++)
    {
        ans += cnt1.at(i)*cnt2.at(i);
    }
    cout << ans << endl;
}
0