結果

問題 No.2947 Sing a Song
ユーザー YU Hirose
提出日時 2024-11-18 16:54:30
言語 Ruby
(3.4.1)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-11-18 16:54:37
合計ジャッジ時間 6,694 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
s, t = gets.chomp.split
a = gets.chomp.split.map &:to_i

a.each do |x|
    res = []
    cnt = x / s.length
    while (x - cnt * s.length) % t.length != 0 do
        cnt -= 1
    end
    cnt.times do
        res << s
    end
    ((x - cnt * s.length)/t.length).times do
        res << t
    end
    puts res.join(" ")
end
0