結果

問題 No.804 野菜が苦手
ユーザー sato_eventsato_event
提出日時 2019-04-11 15:51:42
言語 PHP
(8.3.4)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 12,292 KB
最終ジャッジ日時 2023-09-25 18:50:43
合計ジャッジ時間 1,214 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,176 KB
testcase_01 AC 7 ms
12,168 KB
testcase_02 AC 7 ms
12,244 KB
testcase_03 AC 7 ms
12,196 KB
testcase_04 AC 7 ms
12,196 KB
testcase_05 AC 7 ms
12,268 KB
testcase_06 AC 7 ms
12,248 KB
testcase_07 AC 7 ms
12,288 KB
testcase_08 AC 7 ms
12,232 KB
testcase_09 AC 7 ms
12,280 KB
testcase_10 AC 7 ms
12,260 KB
testcase_11 AC 7 ms
12,292 KB
testcase_12 AC 7 ms
12,192 KB
testcase_13 AC 7 ms
12,244 KB
testcase_14 AC 7 ms
12,216 KB
testcase_15 AC 7 ms
12,248 KB
testcase_16 AC 7 ms
12,248 KB
testcase_17 AC 7 ms
12,196 KB
testcase_18 AC 7 ms
12,292 KB
testcase_19 AC 7 ms
12,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?PHP
$input=trim(fgets(STDIN));  
$arr=explode(' ',$input);
$base_yasai = intval($arr[0]);   // A個の野菜
$base_niku = intval($arr[1]);    // B個の肉
$niku_bai = intval($arr[2]);// C倍の肉
$max = intval($arr[3]);     // 野菜と肉の合計はここ以下になる
$result_yasai = 0;          //食べる野菜
$result_niku = 0;           //食べる肉

//野菜の数まで加算していく
for($i=1; $i<=$base_yasai; $i++){
    //野菜に値して必要な肉を計算
    $desire_niku = $i*$niku_bai;
    //肉が足りているか確認
    if($desire_niku <= $base_niku){
        //足りている場合、許容値を超えないか確認
        if( $i+$desire_niku <= $max){
            $result_yasai = $i;
            $result_niku = $desire_niku;
        }
    }
}
echo $result_yasai;
?>
0