結果
| 問題 |
No.991 N×Mマス計算(構築)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-07-09 06:44:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,271 bytes |
| コンパイル時間 | 433 ms |
| コンパイル使用メモリ | 82,516 KB |
| 実行使用メモリ | 84,816 KB |
| 最終ジャッジ日時 | 2025-07-09 06:45:03 |
| 合計ジャッジ時間 | 5,015 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 TLE * 1 |
| other | -- * 28 |
ソースコード
import sys
input = sys.stdin.readline
from math import sqrt
from random import randint
X=int(input())
while True:
N=randint(round(sqrt(X))+1,round(sqrt(X))*2)
M=randint(round(sqrt(X))+1,round(sqrt(X))*2)
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