結果
| 問題 |
No.991 N×Mマス計算(構築)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-07-09 06:47:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,310 bytes |
| コンパイル時間 | 569 ms |
| コンパイル使用メモリ | 82,540 KB |
| 実行使用メモリ | 80,084 KB |
| 最終ジャッジ日時 | 2025-07-09 06:48:00 |
| 合計ジャッジ時間 | 6,964 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 TLE * 1 -- * 1 |
ソースコード
import sys
input = sys.stdin.readline
from math import sqrt
from random import randint
X=int(input())
while True:
N=randint(round(sqrt(X)),round(sqrt(X))*2+5)
M=randint(round(sqrt(X)),round(sqrt(X))*2+5)
if N==0 or M==0:
continue
for x in range(N+1):
if x*M>X:
break
rest=X-x*M
if rest<0:
break
if rest==0:
y=0
elif N-x==0:
continue
else:
if rest%(N-x)!=0:
continue
else:
y=rest//(N-x)
if y>M:
break
#print(N,M,x,y)
mas=(N-x)*(M-y)
#print(mas)
if mas==0:
continue
# mas * i == X (mod K)
i=round(sqrt(X/mas))
while mas*i*i<=X:
i+=1
if mas*i*i>X:
K=mas*i*i-X
if K>=10**9:
continue
if i>=K:
continue
if (mas*i*i)%K!=X:
#print("!!",K,mas,mas%K)
continue
print(N,M,K)
A=[K]*x+[i]*(N-x)
B=[K]*y+[i]*(M-y)
B=["*"]+B
print(*B)
for a in A:
print(a)
exit()
titia