結果

問題 No.32 貯金箱の憂鬱
ユーザー ant2357ant2357
提出日時 2016-03-23 22:28:12
言語 PHP
(8.3.4)
結果
RE  
実行時間 -
コード長 863 bytes
コンパイル時間 3,933 ms
コンパイル使用メモリ 31,888 KB
実行使用メモリ 32,916 KB
最終ジャッジ日時 2024-04-09 21:12:34
合計ジャッジ時間 5,225 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 AC 36 ms
32,528 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
for($i = 2; $i >= 0; $i--) {
	//貯金箱の中身を取得
	$input = $s = trim(fgets(STDIN));
	$coinList[] = $input[$i];
}

for($i = 0; $i < 3; $i++) {

	if ($i == 0) {
		//両替に必要な枚数
		$exchangeCount = 25;
	} else if($i == 1) {
		//両替に必要な枚数
		$exchangeCount = 4;
	}else if($i == 2) {
		//両替に必要な枚数
		$exchangeCount = 10;
	}

	//両替した際に発生する硬貨の枚数
	$countWhenExchange = floor($coinList[$i] / $exchangeCount);

	if($i == 2){
		//1000円札えの両替を行う
		$coinList[$i] -= $countWhenExchange * $exchangeCount;
	} else if (!$countWhenExchange == 0) {
		//両替を行う
		$coinList[$i + 1] += $countWhenExchange;
		$coinList[$i] -= $countWhenExchange * $exchangeCount ;
	}

}
//硬貨の総数
$coinTotal = $coinList[0] + $coinList[1] + $coinList[2];

echo ($coinTotal.PHP_EOL);
0