結果

問題 No.432 占い(Easy)
ユーザー papinianuspapinianus
提出日時 2016-10-17 12:41:05
言語 PHP
(8.3.4)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 32,088 KB
実行使用メモリ 40,204 KB
最終ジャッジ日時 2024-05-02 03:03:42
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
30,804 KB
testcase_01 AC 37 ms
30,824 KB
testcase_02 AC 35 ms
30,496 KB
testcase_03 AC 34 ms
30,664 KB
testcase_04 AC 32 ms
30,740 KB
testcase_05 AC 32 ms
30,944 KB
testcase_06 AC 36 ms
30,820 KB
testcase_07 AC 36 ms
30,772 KB
testcase_08 AC 33 ms
30,920 KB
testcase_09 AC 35 ms
30,716 KB
testcase_10 AC 34 ms
30,700 KB
testcase_11 AC 38 ms
30,608 KB
testcase_12 AC 88 ms
40,204 KB
testcase_13 AC 87 ms
39,948 KB
testcase_14 AC 41 ms
30,708 KB
testcase_15 AC 33 ms
30,676 KB
testcase_16 AC 34 ms
30,748 KB
testcase_17 AC 70 ms
39,948 KB
testcase_18 AC 60 ms
33,548 KB
testcase_19 AC 54 ms
32,272 KB
testcase_20 AC 41 ms
30,992 KB
testcase_21 AC 42 ms
31,884 KB
testcase_22 AC 35 ms
30,748 KB
testcase_23 AC 35 ms
30,572 KB
testcase_24 AC 35 ms
30,940 KB
testcase_25 AC 35 ms
30,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$t = trim(fgets(STDIN));
for(;$t;$t--)
{
    $nums = str_split(trim(fgets(STDIN)));
    $size = count($nums);
    $val = getTreedSum($nums, $size);
    echo $val.PHP_EOL;
}

function getTreedSum($array, $size)
{
    if($size === 1)
    {
        return $array[0];
    }
    else
    {
        $new = [];
        for($i = 1; $i < $size; $i++)
        {
            $new[$i-1] = singleDigit($array[$i-1], $array[$i]);
        }
        return getTreedSum($new, $size - 1);
    }
}
function singleDigit($a, $b)
{
    $sum = $a + $b;
    while($sum > 9)
    {
        $sum = $sum % 10 + floor($sum / 10);
    }
    return $sum;
}
0