結果

問題 No.800 四平方定理
ユーザー BwambocosBwambocos
提出日時 2019-03-17 23:28:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 166,096 KB
実行使用メモリ 130,160 KB
最終ジャッジ日時 2023-09-22 11:34:52
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
130,004 KB
testcase_01 AC 42 ms
129,940 KB
testcase_02 AC 40 ms
129,964 KB
testcase_03 AC 40 ms
129,960 KB
testcase_04 AC 39 ms
129,840 KB
testcase_05 AC 39 ms
129,992 KB
testcase_06 AC 39 ms
129,936 KB
testcase_07 AC 38 ms
129,844 KB
testcase_08 AC 39 ms
130,068 KB
testcase_09 AC 38 ms
129,916 KB
testcase_10 AC 74 ms
130,068 KB
testcase_11 AC 79 ms
129,964 KB
testcase_12 AC 79 ms
129,852 KB
testcase_13 AC 75 ms
130,140 KB
testcase_14 AC 82 ms
129,940 KB
testcase_15 AC 79 ms
129,892 KB
testcase_16 AC 78 ms
130,000 KB
testcase_17 AC 75 ms
130,152 KB
testcase_18 AC 83 ms
129,844 KB
testcase_19 AC 81 ms
130,000 KB
testcase_20 AC 39 ms
130,004 KB
testcase_21 AC 39 ms
129,840 KB
testcase_22 AC 86 ms
129,952 KB
testcase_23 AC 124 ms
129,932 KB
testcase_24 AC 115 ms
129,940 KB
testcase_25 AC 123 ms
129,924 KB
testcase_26 AC 38 ms
129,996 KB
testcase_27 AC 42 ms
129,984 KB
testcase_28 AC 117 ms
130,136 KB
testcase_29 AC 120 ms
129,876 KB
testcase_30 AC 119 ms
129,948 KB
testcase_31 AC 107 ms
130,140 KB
testcase_32 AC 116 ms
130,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, D;
	in >> N >> D;

	std::vector<LL>cnt1(8123456), cnt2(8123456);
	for (LL x = 1; x <= N; ++x) for (LL y = 1; y <= N; ++y) ++cnt1[x*x + y * y];
	for (LL w = 1; w <= N; ++w) for (LL z = 1; z <= N; ++z) if (w*w - z * z + D > 0)++cnt2[w*w - z * z + D];

	LL ans = 0;
	for (LL i = 1; i <= 2 * N * N; ++i) ans += cnt1[i] * cnt2[i];

	out << ans << std::endl;
}
0