結果

問題 No.800 四平方定理
ユーザー snrnsidysnrnsidy
提出日時 2021-02-21 22:16:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 484 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 208,184 KB
実行使用メモリ 121,284 KB
最終ジャッジ日時 2023-10-19 23:16:21
合計ジャッジ時間 7,106 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
6,228 KB
testcase_01 AC 45 ms
8,404 KB
testcase_02 AC 29 ms
6,912 KB
testcase_03 AC 36 ms
7,492 KB
testcase_04 AC 27 ms
6,792 KB
testcase_05 AC 34 ms
7,292 KB
testcase_06 AC 58 ms
9,380 KB
testcase_07 AC 40 ms
7,928 KB
testcase_08 AC 59 ms
9,536 KB
testcase_09 AC 48 ms
8,520 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

// x^2 + y^2과 w^2 - z^2를 구한다.
map <int,int> cnt1,cnt2;

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++)
		{
			cnt1[a*a + b*b]++;
			cnt2[b*b - a*a]++;
		}
	}
	
	for(auto it : cnt2)
	{
		long long int way = it.second;
		long long int val = it.first + D;
		res += (cnt1[val]*way);
	}
	
	cout << res << '\n';
	return 0;
}
0