結果

問題 No.152 貯金箱の消失
ユーザー pekempeypekempey
提出日時 2016-08-22 17:42:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 841 bytes
コンパイル時間 1,147 ms
コンパイル使用メモリ 159,196 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 11:16:58
合計ジャッジ時間 1,840 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int d = 0;
int d_max = 0;

void iterate_pythagorean_triple(int L, function<void(int, int, int)> f, int x = 3, int y = 4, int z = 5) {
	if (4 * (x + y + z) > L) return;
	f(x, y, z);

	static int M[3][3][3] = {
		{ { 1, -2, 2 }, { 2, -1, 2 }, { 2, -2, 3 } },
		{ { 1, 2, 2 }, { 2, 1, 2 }, { 2, 2, 3 } },
		{ { -1, 2, 2 }, { -2, 1, 2 }, { -2, 2, 3 } } };
	
	for (int i = 0; i < 3; i++) {
		int nx = M[i][0][0] * x + M[i][0][1] * y + M[i][0][2] * z;
		int ny = M[i][1][0] * x + M[i][1][1] * y + M[i][1][2] * z;
		int nz = M[i][2][0] * x + M[i][2][1] * y + M[i][2][2] * z;
		iterate_pythagorean_triple(L, f, nx, ny, nz);
	}
}

int main() {
	int L;
	cin >> L;

	int cnt = 0;
	iterate_pythagorean_triple(L, [&](long long x, long long y, long long z) {
		cnt++;
	});
	cout << cnt << endl;

	return 0;
}
0