結果

問題 No.2513 Power Eraser
ユーザー 👑 amentorimaruamentorimaru
提出日時 2023-09-06 19:56:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 12,020 KB
実行使用メモリ 440,040 KB
最終ジャッジ日時 2023-10-20 21:06:44
合計ジャッジ時間 12,242 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 432 ms
42,768 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 628 ms
58,628 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
7_evil_case_1.txt -- -
7_evil_case_2.txt -- -
7_evil_case_3.txt -- -
7_evil_case_4.txt -- -
7_evil_case_5.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0