結果

問題 No.63 ポッキーゲーム
ユーザー sironekotorosironekotoro
提出日時 2018-12-08 12:17:25
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 4,864 KB
最終ジャッジ日時 2023-10-12 04:58:05
合計ジャッジ時間 1,071 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,676 KB
testcase_01 AC 3 ms
4,676 KB
testcase_02 AC 2 ms
4,612 KB
testcase_03 AC 3 ms
4,608 KB
testcase_04 AC 3 ms
4,608 KB
testcase_05 AC 3 ms
4,844 KB
testcase_06 WA -
testcase_07 AC 3 ms
4,600 KB
testcase_08 AC 3 ms
4,552 KB
testcase_09 AC 3 ms
4,612 KB
testcase_10 AC 3 ms
4,780 KB
testcase_11 AC 3 ms
4,644 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,848 KB
testcase_14 WA -
testcase_15 AC 3 ms
4,656 KB
testcase_16 AC 3 ms
4,612 KB
testcase_17 AC 3 ms
4,620 KB
testcase_18 AC 3 ms
4,672 KB
testcase_19 AC 3 ms
4,784 KB
testcase_20 AC 2 ms
4,640 KB
testcase_21 AC 3 ms
4,804 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use v5.16;

my ( $L, $K ) = split / /, <>;
# my ( $L, $K ) = split / /, "53416 50";
chomp ($L, $K);

# 食べる長さよりもポッキーが短い:0
if ( $L < $K ) {
    say 0;
    exit;
}

# 食べる長さでポッキーが割り切れる
if ( ( $L % $K ) == 0 ) {

    # 割れる数が偶数
    if ( ( $L / $K ) % 2 == 0 ) {

        # 二人が食べられる長さの合計
        my $eat = $L - ( $K * 2 );
        say $eat / 2;
    }

    # 割れた数が奇数
    else {
        my $eat = $L - $K;
        say $eat / 2;
    }

}

# 食べる長さでポッキーが割り切れない
else {
    # 剰余を削り、食べることができる長さを求める
    my $eat = $L - ( $L % $K );

    # 食べることができる長さを二人で割る
    say $eat / 2;
}
0