結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー masakiGit
提出日時 2019-04-18 14:23:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 478 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 63,724 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 09:13:00
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main() {
  int nokori;
  cin >> nokori;
  int kaisu, temochi;
  temochi = 1;
  kaisu = 0;
  if (nokori == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (true) {
    //持ってる枚数で1から総当たりチェック
    for (int i = 1; i <= temochi; i++) {
      if (nokori == (i * 2) + (temochi - i)) {
        cout << kaisu + 1 << endl;
        return 0;
      }
    }
    kaisu++;
    temochi *= 2;
  }
  return 0;
}
0