Submission #33149167


Source Code Expand

Copy
from typing import List
import math
def f(x: int) -> int:
# x
y: int = sum(map(lambda s: ord(s) - ord("0"), str(x)))
return (x + y) % 100000
def main():
#
N, K = map(int, input().split())
# log_2 KM
M: int = math.ceil(math.log2(K))
#
dp: List[List[int]] = [[0 for j in range(100000)] for i in range(M + 1)]
#
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
from typing import List
import math


def f(x: int) -> int:
    # 整数xを文字列として解釈して計算する
    y: int = sum(map(lambda s: ord(s) - ord("0"), str(x)))
    return (x + y) % 100000


def main():
    # 入力受け取り
    N, K = map(int, input().split())

    # log_2 KをMとおく。
    M: int = math.ceil(math.log2(K))

    # ダブリングテーブル
    dp: List[List[int]] = [[0 for j in range(100000)] for i in range(M + 1)]

    # 初期条件
    for j in range(100000):
        dp[0][j] = f(j)

    # 遷移
    for i in range(1, M + 1):
        for j in range(100000):
            dp[i][j] = dp[i - 1][dp[i - 1][j]]

    # 解を求める
    answer: int = N
    i: int = 0
    while K:
        if K & 1:
            answer = dp[i][answer]
        K >>= 1
        i += 1

    print(answer)


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task 058 - Original Calculator(★4)
User fjnkt98
Language PyPy3 (7.3.0)
Score 4
Code Size 914 Byte
Status AC
Exec Time 294 ms
Memory 215496 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 4 / 4
Status
AC × 3
AC × 28
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 03_fixed_01.txt, 03_fixed_02.txt, 03_fixed_03.txt, 03_fixed_04.txt, 03_fixed_05.txt, 03_fixed_06.txt, 04_special_01.txt, 04_special_02.txt, 04_special_03.txt, 04_special_04.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 136 ms 94644 KB
01_sample_02.txt AC 144 ms 124788 KB
01_sample_03.txt AC 289 ms 215372 KB
02_random_01.txt AC 289 ms 215496 KB
02_random_02.txt AC 294 ms 215016 KB
02_random_03.txt AC 287 ms 215448 KB
02_random_04.txt AC 287 ms 215312 KB
02_random_05.txt AC 287 ms 215328 KB
02_random_06.txt AC 285 ms 215300 KB
02_random_07.txt AC 294 ms 215372 KB
02_random_08.txt AC 287 ms 215256 KB
02_random_09.txt AC 292 ms 215496 KB
02_random_10.txt AC 289 ms 215356 KB
02_random_11.txt AC 283 ms 215256 KB
02_random_12.txt AC 287 ms 209264 KB
02_random_13.txt AC 286 ms 215348 KB
02_random_14.txt AC 287 ms 215180 KB
02_random_15.txt AC 288 ms 215344 KB
03_fixed_01.txt AC 158 ms 136804 KB
03_fixed_02.txt AC 288 ms 215304 KB
03_fixed_03.txt AC 289 ms 215044 KB
03_fixed_04.txt AC 290 ms 215356 KB
03_fixed_05.txt AC 289 ms 215436 KB
03_fixed_06.txt AC 114 ms 82196 KB
04_special_01.txt AC 163 ms 136820 KB
04_special_02.txt AC 160 ms 136540 KB
04_special_03.txt AC 165 ms 136772 KB
04_special_04.txt AC 165 ms 137008 KB


2025-04-04 (Fri)
03:30:38 +00:00