結果
問題 | No.97 最大の値を求めるくえり |
ユーザー |
![]() |
提出日時 | 2022-11-12 07:24:13 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 923 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 81,964 KB |
実行使用メモリ | 99,516 KB |
最終ジャッジ日時 | 2024-09-14 00:02:59 |
合計ジャッジ時間 | 7,982 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 1 -- * 16 |
ソースコード
import sys,threadinginput=lambda:sys.stdin.readline().rstrip()x,y,z,w=123456789,362436069,521288629,88675123mod=100003def inv(A):rem=mod-2temp=Aret=1while rem:if rem%2:ret=(ret*temp)%modtemp=(temp**2)%modrem>>=1return retdef calc1(A,Q,ans):ret=0for i in A:ret=max(ret,(Q*i)%mod)if ans[0]!=-1:returnans[0]=retdef calc2(B,Q,ans):invQ=inv(Q)for i in range(mod-1,-1,-1):if (i*invQ)%mod in B:ans[0]=ireturnif ans[0]!=-1:returnN,M=map(int,input().split())A=[0]*Nfor i in range(N):t=x^((x<<11)%(1<<32))x,y,z=y,z,ww=w^(w>>19)^(t^(t>>8))A[i]=w%modB=set(A)for i in range(M):Q=int(input())if Q==0:print(0)continueans=[-1]th1=threading.Thread(target=calc1,args=(A,Q,ans))th2=threading.Thread(target=calc2,args=(B,Q,ans))th1.start()th2.start()for i in threading.enumerate():if threading.main_thread()!=i:i.join()print(ans[0])