結果
問題 |
No.2513 Power Eraser
|
ユーザー |
![]() |
提出日時 | 2023-09-06 19:56:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,003 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 61,696 KB |
最終ジャッジ日時 | 2024-09-20 17:10:13 |
合計ジャッジ時間 | 11,273 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 1 TLE * 1 -- * 37 |
ソースコード
import sys import numpy as np input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for _ in range(N)] mod=998244353 def main(): n=int(input()) a=read_list() na=np.array([a],dtype=object) ta=na.T aa=na-ta ans=1 for i in range(n): aa[i][i]=1 ans*=aa[i].prod() ans%=mod if ans==0: print(0) return if n%4==2 or n%4==1: ans=mod-ans s=set() now=1 for i in range(40000): s.add(now) now*=3 now%=mod p=0 rev=pow(now,-1,mod) rev3=pow(3,-1,mod) while not ans in s: p+=40000 ans*=rev ans%=mod while ans>1: p+=1 ans*=rev3 ans%=mod if p%2: p=(p+mod)//2 else: p=p//2 print(pow(3,p,mod)) if __name__ == "__main__": main()