結果
問題 | No.319 happy b1rthday 2 me |
ユーザー |
![]() |
提出日時 | 2015-12-12 17:48:28 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 2,442 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-12-26 04:17:01 |
合計ジャッジ時間 | 5,636 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
コンパイルメッセージ
Main.rb:19: warning: assigned but unused variable - an Main.rb:19: warning: assigned but unused variable - bn Main.rb:23: warning: assigned but unused variable - ch Main.rb:24: warning: assigned but unused variable - ss Syntax OK
ソースコード
#happy b1rthday 2 medef comb(n, m)q = 1m.times do |x|q *= n - xq /= (x + 1)endreturn qenda, b = gets.splitif a == bcount = 0(a.length - 1).times do |i|count += 1 if a[i, 2] == "12"endputs countexitendan, bn = a.to_i, b.to_ila = a.lengthlb = b.lengthres = 0ch = 0ss = ""=begin(a.to_i).upto(b.to_i) do |x|ss += x.to_send(ss.length - 1).times do |i|ch += 1 if ss[i, 2].to_i == 12endputs ch=endla.upto(lb) do |x|if x == 1res += 1nextendd = x - 2res += 10 ** dres += d * 9 * 10 ** (d - 1) if d > 0if x >= 3res += 10 ** (x - 2)elseres += 1endendy = 2(la - y).downto(0) do |i|j = la - i - yq = 0mid = a[i, y].to_ileft = a[0, i].to_iright = a[i + y, j].to_iif i == 0if mid > 12q += 10 ** jelsif mid == 12q += rightendelsif i == la - yq += left - 10 ** (i - 1)q += 1 if mid > 12elseif mid > 12q += (left - 10 ** (i - 1) + 1) * 10 ** jelsif mid < 12q += (left - 10 ** (i - 1)) * 10 ** jelseq += (left - 10 ** (i - 1)) * 10 ** jq += rightendendres -= qendif a.length - 2 >= 0if a[0].to_i > 2res -= 10 ** (a.length - 2)elsif a[0].to_i == 2res -= a[1, a.length - 2].to_i + 1res += 1 if a[a.length - 1].to_i < 2endelseif a[0].to_i >= 2res -= 1endend(lb - y).downto(0) do |i|j = lb - i - yq = 0mid = b[i, y].to_ileft = b[0, i].to_iright = b[i + y, j].to_iif i == 0if mid < 12q += 10 ** jelsif mid == 12q += 10 ** j - right - 1endelsif i == lb - yq += 10 ** i - leftq -= 1 if mid >= 12elseif mid < 12q += (10 ** i - left) * 10 ** jelsif mid > 12q += (10 ** i - left - 1) * 10 ** jelseq += (10 ** i - left - 1) * 10 ** jq += 10 ** j - right - 1endendres -= qendif b.length - 2 >= 0if b[0].to_i < 2res -= 10 ** (b.length - 2)elsif b[0].to_i == 2res -= 10 ** (b.length - 2) - b[1, b.length - 2].to_ires += 1 if b[b.length - 1].to_i >= 2endendputs res