結果

問題 No.432 占い(Easy)
ユーザー harhogefooharhogefoo
提出日時 2016-10-14 22:38:12
言語 Ruby
(3.2.2)
結果
AC  
実行時間 475 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 11,220 KB
実行使用メモリ 23,032 KB
最終ジャッジ日時 2023-08-14 11:14:08
合計ジャッジ時間 4,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,016 KB
testcase_01 AC 81 ms
15,092 KB
testcase_02 AC 81 ms
15,196 KB
testcase_03 AC 83 ms
15,236 KB
testcase_04 AC 88 ms
15,408 KB
testcase_05 AC 84 ms
15,008 KB
testcase_06 AC 80 ms
15,096 KB
testcase_07 AC 89 ms
15,364 KB
testcase_08 AC 83 ms
15,108 KB
testcase_09 AC 83 ms
15,204 KB
testcase_10 AC 85 ms
15,264 KB
testcase_11 AC 121 ms
15,380 KB
testcase_12 AC 475 ms
19,824 KB
testcase_13 AC 473 ms
19,836 KB
testcase_14 AC 121 ms
15,140 KB
testcase_15 AC 84 ms
15,188 KB
testcase_16 AC 83 ms
15,020 KB
testcase_17 AC 151 ms
23,032 KB
testcase_18 AC 275 ms
17,408 KB
testcase_19 AC 209 ms
16,624 KB
testcase_20 AC 139 ms
15,400 KB
testcase_21 AC 147 ms
15,508 KB
testcase_22 AC 85 ms
15,224 KB
testcase_23 AC 86 ms
15,068 KB
testcase_24 AC 85 ms
15,280 KB
testcase_25 AC 84 ms
15,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

t = gets.to_i

def calc(ary)
  if ary.length == 1
    return ary
  end
  a = Array.new
  (ary.length-1).times do |i|
    ans = ary[i] + ary[i+1]
    while ans >= 10
      ans = ans.to_s.split("").map(&:to_i)
      ans = ans.inject(:+)
    end
    a.push(ans)
  end
  calc(a)
end

t.times do
  s = gets.chomp.split("").map(&:to_i)
  puts calc(s)
end
0