結果

問題 No.634 硬貨の枚数1
ユーザー しらっ亭
提出日時 2017-05-10 16:16:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 492 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 62,496 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-25 18:16:17
合計ジャッジ時間 3,023 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 74 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <assert.h>

using namespace std;

int solve(int n) {
  vector<int> T;
  for (int t, i = 1; (t = i * (i + 1) / 2) <= n; i++) {
    T.emplace_back(t);
  }

  for (int t1 : T) {
    if (t1 == n) {
      return 1;
    }

    for (int t2 : T) {
      if (t1 + t2 == n) {
        return 2;
      }
    }
  }
  return 3;
}

int main() {
  int n;
  cin >> n;
  assert(n >= 1);
  assert(n <= 10000000);
  cout << solve(n) << endl;
}
0