結果

問題 No.3365 Prefix and Suffix X
コンテスト
ユーザー Koi
提出日時 2025-10-29 23:55:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 578 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 250 ms
コンパイル使用メモリ 95,728 KB
実行使用メモリ 86,144 KB
最終ジャッジ日時 2026-07-16 17:02:47
合計ジャッジ時間 61,833 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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