結果
| 問題 |
No.47 ポケットを叩くとビスケットが2倍
|
| コンテスト | |
| ユーザー |
aparachia14
|
| 提出日時 | 2016-01-16 00:20:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,056 bytes |
| コンパイル時間 | 3,360 ms |
| コンパイル使用メモリ | 74,500 KB |
| 実行使用メモリ | 50,320 KB |
| 最終ジャッジ日時 | 2024-09-19 19:42:08 |
| 合計ジャッジ時間 | 5,255 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 7 |
ソースコード
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 if(want2 == 1){
counter++;
}else if(want2 % 2 == 0){
counter++;
}else if(want2 % 2 == 1){
counter = counter + 2;
}else{
}
System.out.println(counter);
}
}
aparachia14