結果
問題 |
No.47 ポケットを叩くとビスケットが2倍
|
ユーザー |
![]() |
提出日時 | 2016-01-18 22:51:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 929 bytes |
コンパイル時間 | 3,364 ms |
コンパイル使用メモリ | 74,568 KB |
実行使用メモリ | 50,444 KB |
最終ジャッジ日時 | 2024-09-21 07:58:41 |
合計ジャッジ時間 | 5,589 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; //No.47 ポケットを叩くとビスケットが2倍 public class TwiceBiscuit { public static void main(String[] args) throws IOException { // TODO 自動生成されたメソッド・スタブ //食べたいビスケットの枚数 int want; //ビスケットの枚数 int biscuit = 1; //カウンタ int counter = 0; //入力受け取り BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); want = Integer.parseInt(in.readLine()); while(true){ biscuit = biscuit * 2; if(biscuit > want){ break; }else{ } counter++; } //あと欲しい数 int want2 = want - (biscuit / 2); //want2を2で割った余りが0ならcounterに+1 余りが1ならcounterに+2 if(want2 == 0){ }else{ counter++; } System.out.println(counter); } }