結果
| 問題 |
No.3365 Prefix and Suffix X
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-11-22 20:47:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 388 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 79,372 KB |
| 最終ジャッジ日時 | 2025-11-22 20:48:54 |
| 合計ジャッジ時間 | 76,786 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 30 |
ソースコード
T=int(input())
for _ in range(T):
X,M=map(int,input().split())
q=[-1]*1000
for i in range(1000):
j=(M*i)%1000
if q[j]==-1:
q[j]=M*i
ans=-1
for i in range(20):
Y=X*(10**i)
Y+=(-Y)%M
Y+=q[(X-Y)%1000]
lx=len(str(X))
ly=len(str(Y))
if Y%M==0 and lx<=ly<=18 and str(Y)[:lx]==str(Y)[-lx:]==str(X):
ans=Y
for i in range(20):
Y=(X-1)*(10**i)
Y+=(-Y)%M
Y+=q[(X-Y)%1000]
lx=len(str(X))
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