結果

問題 No.800 四平方定理
ユーザー snrnsidysnrnsidy
提出日時 2021-02-21 22:19:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 476 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 200,816 KB
実行使用メモリ 34,828 KB
最終ジャッジ日時 2023-10-19 23:18:57
合計ジャッジ時間 7,596 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
6,260 KB
testcase_02 AC 3 ms
6,260 KB
testcase_03 AC 3 ms
6,260 KB
testcase_04 AC 3 ms
6,260 KB
testcase_05 AC 3 ms
6,260 KB
testcase_06 AC 3 ms
6,260 KB
testcase_07 AC 3 ms
6,260 KB
testcase_08 AC 3 ms
6,208 KB
testcase_09 AC 3 ms
6,260 KB
testcase_10 AC 39 ms
33,676 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

// x^2 + y^2과 w^2 - z^2를 구한다.
long long int cnt[4000001];

int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,D;
	int res = 0;
	cin >> n >> D;
	
	for(int a=1;a<=n;a++)
	{
		for(int b=1;b<=n;b++)
		{
			cnt[a*a + b*b]++;
		}
	}
	
	for(int a=1;a<=n;a++)
	{
		for(int b=1;b<=n;b++)
		{
			int val = b*b - a*a + D;
			if(val>=0)
			{
				res += cnt[val];
			}
		}
	}
	
	cout << res << '\n';
	return 0;
}
0