結果
| 問題 | No.3365 Prefix and Suffix X |
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-11-23 02:02:06 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,190 ms / 2,000 ms |
| + 456µs | |
| コード長 | 339 bytes |
| 記録 | |
| コンパイル時間 | 288 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 85,344 KB |
| 最終ジャッジ日時 | 2026-07-16 22:41:35 |
| 合計ジャッジ時間 | 41,029 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
T=int(input())
for _ in range(T):
X,M=map(int,input().split())
lx=len(str(X))
q=[-1]*10**lx
for i in range(1000):
j=(M*i)%(10**lx)
if q[j]==-1:
q[j]=M*i
ans=-1
Y=X*(10**15)
Y+=(-Y)%M
Y+=q[(X-Y)%(10**lx)]
ly=len(str(Y))
if Y%M==0 and lx<=ly<=18 and str(Y)[:lx]==str(Y)[-lx:]==str(X):
ans=Y
print(ans)
sasa8uyauya