結果

問題 No.3301 Make Right Triangle
ユーザー rurun
提出日時 2025-10-05 16:06:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 194,996 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-05 16:06:38
合計ジャッジ時間 7,112 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T>
vector<pair<T, int>> factorize(T n) {
  vector<pair<T, int>> res;
  for (T i = 2; i*i <= n; i++) {
    if (n%i == 0) {
      int cnt = 0;
      while (n%i == 0) cnt++, n/=i;
      res.emplace_back(make_pair(i, cnt));
    }
  }
  if (n != 1) res.emplace_back(make_pair(n, 1));
  return res;
}

void solve(lint n) {
  if (n%4 == 0) {
    cout << 3LL*(n/4) << " " << 4LL*(n/4) << " " << 5LL*(n/4) << endl;
  }
  else {
    lint p = n;
    while (p%2 == 0) p/=2;
    cout << (p*p/2)*(n/p) << " " << p*(n/p) << " " << (p*p/2+1)*(n/p) << endl;
  }
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    lint l;
    cin >> l;
    solve(l);
  }
}
0