結果
問題 |
No.152 貯金箱の消失
|
ユーザー |
|
提出日時 | 2016-08-22 17:42:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 841 bytes |
コンパイル時間 | 2,311 ms |
コンパイル使用メモリ | 159,220 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 22:35:52 |
合計ジャッジ時間 | 2,471 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#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; }