結果

問題 No.432 占い(Easy)
ユーザー papinianuspapinianus
提出日時 2016-10-17 12:41:05
言語 PHP
(8.3.4)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 16,768 KB
実行使用メモリ 35,064 KB
最終ジャッジ日時 2023-08-14 14:56:34
合計ジャッジ時間 3,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
17,060 KB
testcase_01 AC 12 ms
16,996 KB
testcase_02 AC 12 ms
17,008 KB
testcase_03 AC 13 ms
16,976 KB
testcase_04 AC 12 ms
17,436 KB
testcase_05 AC 12 ms
17,012 KB
testcase_06 AC 12 ms
17,020 KB
testcase_07 AC 12 ms
17,356 KB
testcase_08 AC 12 ms
17,064 KB
testcase_09 AC 12 ms
16,924 KB
testcase_10 AC 13 ms
17,072 KB
testcase_11 AC 17 ms
17,168 KB
testcase_12 AC 76 ms
35,048 KB
testcase_13 AC 74 ms
35,064 KB
testcase_14 AC 19 ms
17,352 KB
testcase_15 AC 13 ms
16,816 KB
testcase_16 AC 12 ms
16,924 KB
testcase_17 AC 55 ms
35,004 KB
testcase_18 AC 43 ms
23,344 KB
testcase_19 AC 33 ms
20,184 KB
testcase_20 AC 22 ms
18,172 KB
testcase_21 AC 22 ms
19,472 KB
testcase_22 AC 13 ms
17,072 KB
testcase_23 AC 13 ms
17,016 KB
testcase_24 AC 14 ms
17,016 KB
testcase_25 AC 14 ms
17,052 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