結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-16 22:50:09 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 660 bytes |
| コンパイル時間 | 42 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-09-17 10:39:34 |
| 合計ジャッジ時間 | 6,777 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
def scan; gets.split.map(&:to_i); end
# abababa
def func(n)
m = (n+1) / 2
k = m*(m-1)-m+1
(n.even? ? k*2 : k) + n
end
n = gets.to_i
iwi = ['a','b']
offset = 0
while n > 3
# binary search
c = nil
l = 0; h = 100000
while l < h
c = (l+h+1)/2;
if (n < func(c))
h = c-1
else
l = c
end
end
k = l
n -= func(l)
print ((iwi[0]+iwi[1])*((k)/2))[offset..-1]
if k.odd?
print iwi[0]
iwi[1].succ!
offset = 1
else
iwi[0] = iwi[1].clone
iwi[1].succ!
offset = 1
end
end
print 'xyz'[0..(n-1)] if 0 < n