結果
| 問題 |
No.3301 Make Right Triangle
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2025-10-05 14:47:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,378 bytes |
| コンパイル時間 | 1,000 ms |
| コンパイル使用メモリ | 80,984 KB |
| 実行使用メモリ | 10,784 KB |
| 最終ジャッジ日時 | 2025-10-05 14:47:23 |
| 合計ジャッジ時間 | 5,623 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 1 TLE * 1 -- * 7 |
ソースコード
// L素数が本質なのはすぐ分かるが、そこからが苦手。
// このテーブルを眺めていたら、aが素数のとき、a=m+n, m=n+1が見えた。
// https://mathlandscape.com/pythagoras-triple-table/
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <atcoder/modint>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
using namespace atcoder;
void solve(int L) {
if (L % 4 == 0) {
cout << (L / 4) * 3 << " " << (L / 4) * 4 << " " << (L / 4) * 5 << endl;
return;
}
int i;
vector<int> ps, es;
int tmp = L;
for (i = 2; i * i <= tmp; i++) {
int cnt = 0;
while (tmp % i == 0) {
tmp /= i;
cnt++;
}
if (cnt > 0) {
ps.push_back(i);
es.push_back(cnt);
}
}
if (tmp > 1) { ps.push_back(tmp); es.push_back(1); }
int p = ps.back();
int m = (p + 1) / 2, n = p / 2;
int bai = L / p;
cout << (m * m - n * n) * bai << " " << (m * m + n * n) * bai << " " << 2 * m * n * bai << endl;
}
signed main() {
int T;
cin >> T;
while (T--) {
int L; cin >> L;
solve(L);
}
return 0;
}
startcpp