結果

問題 No.800 四平方定理
ユーザー snrnsidysnrnsidy
提出日時 2021-02-21 22:20:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 200,720 KB
実行使用メモリ 34,208 KB
最終ジャッジ日時 2023-10-19 23:19:03
合計ジャッジ時間 3,929 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
6,260 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
6,208 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 23 ms
20,596 KB
testcase_11 AC 28 ms
22,644 KB
testcase_12 AC 28 ms
22,644 KB
testcase_13 AC 24 ms
20,596 KB
testcase_14 AC 24 ms
22,644 KB
testcase_15 AC 27 ms
22,644 KB
testcase_16 AC 27 ms
22,644 KB
testcase_17 AC 27 ms
22,644 KB
testcase_18 AC 29 ms
22,644 KB
testcase_19 AC 31 ms
22,644 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 30 ms
22,644 KB
testcase_23 AC 77 ms
34,208 KB
testcase_24 AC 69 ms
34,208 KB
testcase_25 AC 74 ms
34,116 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 70 ms
34,060 KB
testcase_29 AC 72 ms
34,152 KB
testcase_30 AC 68 ms
34,092 KB
testcase_31 AC 60 ms
32,884 KB
testcase_32 AC 69 ms
34,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

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

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