結果

問題 No.254 文字列の構成
ユーザー maimai
提出日時 2017-05-16 23:37:09
言語 Ruby
(3.2.2)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 16,048 KB
最終ジャッジ日時 2023-10-17 12:34:42
合計ジャッジ時間 4,030 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
16,048 KB
testcase_01 AC 81 ms
16,048 KB
testcase_02 AC 81 ms
16,048 KB
testcase_03 AC 80 ms
16,048 KB
testcase_04 AC 81 ms
16,048 KB
testcase_05 AC 80 ms
16,048 KB
testcase_06 AC 80 ms
16,048 KB
testcase_07 AC 81 ms
16,048 KB
testcase_08 AC 81 ms
16,048 KB
testcase_09 AC 80 ms
16,048 KB
testcase_10 AC 82 ms
16,044 KB
testcase_11 AC 80 ms
16,048 KB
testcase_12 AC 81 ms
16,048 KB
testcase_13 AC 81 ms
16,048 KB
testcase_14 AC 81 ms
16,048 KB
testcase_15 AC 81 ms
16,044 KB
testcase_16 AC 81 ms
16,048 KB
testcase_17 AC 81 ms
16,048 KB
testcase_18 AC 81 ms
16,048 KB
testcase_19 AC 81 ms
16,048 KB
testcase_20 AC 82 ms
16,048 KB
testcase_21 AC 81 ms
16,048 KB
testcase_22 AC 80 ms
16,048 KB
testcase_23 AC 81 ms
16,048 KB
testcase_24 AC 80 ms
16,044 KB
testcase_25 AC 81 ms
16,048 KB
testcase_26 AC 80 ms
16,048 KB
testcase_27 AC 81 ms
16,048 KB
testcase_28 AC 80 ms
16,048 KB
testcase_29 AC 81 ms
16,048 KB
testcase_30 AC 82 ms
16,048 KB
testcase_31 AC 81 ms
16,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def scan; gets.split.map(&:to_i); end

# abababa
def func(n)
    m = (n+2) / 2
    return (n.even? ? (m-2)*(m-1) : m*(m-1)-m+1) + n
end

n = gets.to_i
puts "🍣" if n <= 0
iwi = ['a','b']

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))
    print iwi[0] if k.odd?
    
    iwi.map!(&:succ!).map!(&:succ!)
end

print 'xyz'[0..(n-1)] if 0 < n

0