結果

問題 No.800 四平方定理
ユーザー polylogKpolylogK
提出日時 2019-03-17 21:32:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 166,120 KB
実行使用メモリ 34,424 KB
最終ジャッジ日時 2023-09-22 04:02:55
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 29 ms
18,484 KB
testcase_11 AC 32 ms
20,384 KB
testcase_12 AC 33 ms
20,260 KB
testcase_13 AC 28 ms
19,180 KB
testcase_14 AC 31 ms
20,500 KB
testcase_15 AC 36 ms
20,252 KB
testcase_16 AC 31 ms
20,448 KB
testcase_17 AC 30 ms
20,768 KB
testcase_18 AC 36 ms
20,412 KB
testcase_19 AC 37 ms
20,432 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 40 ms
20,764 KB
testcase_23 AC 85 ms
34,424 KB
testcase_24 AC 79 ms
34,188 KB
testcase_25 AC 78 ms
34,392 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 79 ms
34,016 KB
testcase_29 AC 81 ms
34,228 KB
testcase_30 AC 76 ms
34,360 KB
testcase_31 AC 72 ms
32,032 KB
testcase_32 AC 78 ms
34,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, d; scanf("%d%d", &n, &d);
	
	std::vector<int> vec(2 * n * n + 1, 0);
	for(i64 i = 1; i <= n; i++) {
		for(i64 j = 1; j <= n; j++) {
			vec[i * i + j * j]++;
		}
	}
	
	i64 ans = 0;
	for(i64 i = 1; i <= n; i++) {
		for(i64 j = 1; j <= n; j++) {
			i64 latte = i * i - j * j + d;
			if(latte > vec.size() or latte < 0) continue;
			
			ans += vec[latte];
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0