結果

問題 No.3525 擬奇平方数
コンテスト
ユーザー 👑 p-adic
提出日時 2025-05-06 14:17:15
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,880 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 696 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 35,588 KB
平均クエリ数 876.53
最終ジャッジ日時 2026-05-01 21:03:55
合計ジャッジ時間 16,136 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def O(*a):print(*a,flush=True)
I=input
N=num=1;num+=1
O('a',N,'r',N);one=num;num+=1									#1
O('a',one,'+',one);two=num;num+=1								#2
O('a',two,'+',one);three=num;num+=1								#3
O('a',two,'r',N);rN=num;num+=1									#floor(sqrt(N))
O('a',rN,'*',rN);rN2=num;num+=1									#floor(sqrt(N))^2
D=50
loop=17
square_query=[0]*D
decision_query=[0]*D
R=range(D)
for r in R:
	t=[rN,num-loop][r>0]												#t:=floor(sqrt(N))+r
	O('a',t,'+',one);						t=num;num+=1				#t:=floor(sqrt(N))+r
	O('a',t,'*',t);							t2=num;num+=1				#t^2
	O('a',t2,'-',N);						t2mN=num;num+=1				#t^2-N
	O('a',two,'r',t2mN);					rt2mN=num;num+=1			#floor(sqrt(t^2-N))
	O('a',rt2mN,'*',rt2mN);					rt2mN2=num;num+=1			#floor(sqrt(t^2-N))^2
	O('a',t,'-',rt2mN);						d=num;num+=1				#d:=t-floor(sqrt(t^2-N))
	O('a',d,'*',d);							d2=num;num+=1				#d^2
	O('a',d2,'*',d);						d3=num;num+=1				#d^3
	O('a',three,'*',d2);					threed2=num;num+=1			#3d^2
	O('a',threed2,'+',N);					Npthreed2=num;num+=1		#N+3d^2
	O('a',Npthreed2,'*',Npthreed2);			Npthreed22=num;num+=1		#(N+3d^2)^2
	O('a',Npthreed22,'*',N);				Npthreed22N=num;num+=1		#(N+3d^2)^2*N
	O('a',three,'*',d);						threed=num;num+=1			#3d
	O('a',threed,'+',one);					threedp1=num;num+=1			#3d+1
	O('a',threedp1,'*',N);					threedp1N=num;num+=1		#(3d+1)*N
	O('a',threedp1N,'+',d3);				threedp1Npd3=num;num+=1		#(3d+1)*N+d^3
	O('a',threedp1Npd3,'*',threedp1Npd3);	threedp1Npd32=num;num+=1	#((3d+1)*N+d^3)^2
	square_query[r]=[rt2mN2,t2mN]
	decision_query[r]=[threedp1Npd32,Npthreed22N]
O('?',rN2,'<',N)											#floor(sqrt(t^2-N))^2<t^2-N
if I()<'T':
	exit(O("! Yes"))
for r in R:
	rt2mN2,t2mN=square_query[r]
	O('?',rt2mN2,'<',t2mN);									#floor(sqrt(t^2-N))^2<t^2-N
	if I()<'T':
		threedp1Npd32,Npthreed22N=decision_query[r]
		O('?',threedp1Npd32,'<',Npthreed22N)				#((3d+1)*N+d^3)^2<(N+3d^2)^2*N
		exit(O("!","YNeos"[I()>'F'::2]))
O("! No")
0