結果
| 問題 |
No.757 チャンパーノウン定数 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-05 11:22:26 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,022 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 95,136 KB |
| 最終ジャッジ日時 | 2024-07-18 11:12:04 |
| 合計ジャッジ時間 | 62,457 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 6 WA * 40 TLE * 5 |
コンパイルメッセージ
Main.rb:44: warning: assigned but unused variable - sz Main.rb:46: warning: assigned but unused variable - l Syntax OK
ソースコード
B = gets.to_i
#N = gets.to_i(B)
N = 3**100000
# guchoku
# str = ((0..999).map{|e|e.to_s(B)}*"")
# puts str[0..50]
# puts str[N]
def dig(y, sz, w)
# range "000".."999"
i = y/w
d = y%w
i.to_s(B)[d] || "0"
end
# deprecated
def climb(x, sz, ofs, w)
# range "100".."999"
len = (sz-ofs)*w
# p [x,sz,ofs,w]
# p (ofs...sz).map{|e|e.to_s(B)}
if x >= len
climb(x-len, sz*B, sz, w+1)
else
# p B**(w-1)
# ((ofs...sz).map{|e|e.to_s(B)}*"")[x]
dig(x+B**(w-1)*w, sz, w)
end
end
def climb_flat(x, sz, ofs, w)
len = (sz-ofs)*w
while x >= len
x, sz, ofs, w = x-len, sz*B, sz, w+1
len = (sz-ofs)*w
end
dig(x+B**(w-1)*w, sz, w)
end
def climb_flat2(x)
sz, ofs, w = B, 1, 1
len = (B-1)*w
l = len
while x >= len
x, ofs, w = x-len, ofs*B, w+1
len = ofs*(w*(B-1))
end
dig(x+len/(B-1), ofs*B, w)
end
if N == 0
p 0
else
# puts climb_flat(N-1, B, 1, 1)
puts climb_flat2(N-1)
end