結果

問題 No.800 四平方定理
ユーザー BwambocosBwambocos
提出日時 2019-03-17 23:28:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 168,648 KB
実行使用メモリ 130,288 KB
最終ジャッジ日時 2024-07-08 03:24:02
合計ジャッジ時間 4,183 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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