結果

問題 No.1915 Addition
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-04-29 21:46:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 871 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 71,692 KB
最終ジャッジ日時 2023-09-11 12:45:00
合計ジャッジ時間 4,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,692 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

Mの桁数をkとする

B = N*(10^k) + M
A = N+M

B%A = 

Aは1ずつ
Bは10^k ずつ増える

N*(10^k-1) が N+M で割り切れる
N*(99999) が N+M で割り切れる

N*9 が N+M (1 <= M < 10)

"""

import sys
from sys import stdin

TT = int(stdin.readline())

for loop in range(TT):

    N = int(stdin.readline())

    for bit in range(max(1,len(str(N))-1),12):

        Q = (10**bit-1) * N

        flag = False
        for i in range(1,int(Q**0.5+10)):

            if Q % i == 0:
                x = i
                M = x - N
                if M > 0 and len(str(M)) == bit:
                    flag = True
                    break
                x = Q // i
                M = x - N
                if M > 0 and len(str(M)) == bit:
                    flag = True
                    break

        if flag:
            break
        

    print (M)
0