結果

問題 No.428 小数から逃げる夢
ユーザー lam6er
提出日時 2025-03-20 20:19:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 1,000 ms
コード長 1,132 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 54,420 KB
最終ジャッジ日時 2025-03-20 20:20:29
合計ジャッジ時間 6,292 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

def create_S():
    current = []
    num = 1
    length = 0
    while length < 190:
        s = str(num)
        remaining = 190 - length
        if len(s) <= remaining:
            current.append(s)
            length += len(s)
        else:
            current.append(s[:remaining])
            length = 190
        num += 1
    return ''.join(current)

def multiply_str_num(s, n):
    if n == 0:
        return '0'
    reversed_s = s[::-1]
    result = []
    carry = 0
    for ch in reversed_s:
        digit = int(ch)
        product = digit * n + carry
        carry = product // 10
        result.append(product % 10)
    if carry != 0:
        result.append(carry)
    # Convert to string and remove leading zeros
    result_str = ''.join(map(str, reversed(result))).lstrip('0')
    return result_str if result_str else '0'

S = create_S()
N = int(input())
product_str = multiply_str_num(S, N)
L = len(product_str)

if L > 190:
    integer_part = product_str[:-190]
    fractional_part = product_str[-190:]
else:
    integer_part = '0'
    fractional_part = product_str.zfill(190)

print(f"{integer_part}.{fractional_part}")
0