結果

問題 No.634 硬貨の枚数1
ユーザー k
提出日時 2020-09-05 05:24:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 2,733 ms
コンパイル使用メモリ 194,092 KB
最終ジャッジ日時 2025-01-14 06:56:41
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;

  vector<int> tr;
  for (int k = 1; k * (k+1) / 2 <= n; k++) {
    tr.push_back(k * (k+1) / 2);
  }

  int ret = 3;
  for (int a: tr) {
    if (a == n)
      ret = min(ret, 1);
    for (int b: tr) {
      if (a + b == n)
        ret = min(ret, 2);
    }
  }

  cout << ret << endl;
  
  return 0;
}
0