結果
| 問題 | No.47 ポケットを叩くとビスケットが2倍 |
| コンテスト | |
| ユーザー |
oga00826
|
| 提出日時 | 2019-05-21 13:42:11 |
| 言語 | PHP (843.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 654 bytes |
| 記録 | |
| コンパイル時間 | 2,537 ms |
| コンパイル使用メモリ | 31,888 KB |
| 実行使用メモリ | 32,528 KB |
| 最終ジャッジ日時 | 2024-09-17 08:58:31 |
| 合計ジャッジ時間 | 4,089 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 21 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
$n = trim(fgets(STDIN));
$biscuit = 1;
$all = 0;
$answer = "";
for($i=1; $i<=$n; $i++) {
if ($i == 1) $biscuit = 1;
else $biscuit = $all;
$all = pocket($biscuit);
if ($all == $n) {
$answer = $i;
break;
} elseif ($all > $n) {
$amari = $all - $n;
if ($amari == 1) {
$answer = $i;
break;
} else {
$res = $amari % 2;
if ($res == 0) {
$answer = $i;
} else {
$answer = $i + 1;
}
break;
}
}
}
function pocket($biscuit) {
return $biscuit*2;
}
echo $answer."\n";
oga00826