結果

問題 No.3365 Prefix and Suffix X
コンテスト
ユーザー Koi
提出日時 2025-10-29 23:55:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 578 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 93,756 KB
最終ジャッジ日時 2025-11-17 20:41:04
合計ジャッジ時間 7,373 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

def tle(X, M):
    for i in range(1000):
        S = str(i * M)
        if(len(S) >= len(str(X)) and S[-len(str(X)):] == str(X)):
            f = X * 10 ** 10
            if(f % M != 0):
                f += (M - f % M)
            ans = str(f * 1000 + M * i)
            assert(len(str(X)) <= len(ans) <= 18)
            assert(int(ans) % M == 0)
            assert(ans[:len(str(X))] == str(X))
            assert(ans[-len(str(X)):] == str(X))
            return ans
    return -1

T = int(input())
for _ in range(T):
    X, M = map(int, input().split())
    print(tle(X, M))

0