結果

問題 No.1741 Arrays and XOR Procedure
ユーザー puznekopuzneko
提出日時 2021-11-25 00:11:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 990 bytes
コンパイル時間 1,341 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 114,044 KB
最終ジャッジ日時 2023-09-09 17:08:36
合計ジャッジ時間 9,030 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,236 KB
testcase_01 AC 73 ms
71,160 KB
testcase_02 AC 72 ms
71,300 KB
testcase_03 AC 131 ms
114,044 KB
testcase_04 AC 71 ms
71,280 KB
testcase_05 AC 130 ms
113,080 KB
testcase_06 AC 142 ms
113,360 KB
testcase_07 AC 141 ms
113,628 KB
testcase_08 AC 131 ms
113,184 KB
testcase_09 AC 126 ms
108,620 KB
testcase_10 AC 129 ms
108,956 KB
testcase_11 AC 131 ms
109,232 KB
testcase_12 AC 115 ms
99,060 KB
testcase_13 AC 130 ms
108,460 KB
testcase_14 AC 129 ms
104,912 KB
testcase_15 AC 125 ms
104,984 KB
testcase_16 AC 87 ms
76,240 KB
testcase_17 AC 104 ms
88,932 KB
testcase_18 AC 131 ms
105,696 KB
testcase_19 AC 87 ms
76,232 KB
testcase_20 AC 138 ms
113,328 KB
testcase_21 AC 132 ms
110,376 KB
testcase_22 AC 127 ms
104,344 KB
testcase_23 AC 101 ms
86,680 KB
testcase_24 AC 86 ms
76,180 KB
testcase_25 AC 135 ms
112,956 KB
testcase_26 AC 105 ms
91,688 KB
testcase_27 AC 84 ms
76,304 KB
testcase_28 AC 123 ms
104,992 KB
testcase_29 AC 127 ms
105,408 KB
testcase_30 AC 132 ms
108,264 KB
testcase_31 AC 87 ms
76,396 KB
testcase_32 AC 109 ms
93,204 KB
testcase_33 AC 109 ms
95,776 KB
testcase_34 AC 93 ms
82,456 KB
testcase_35 AC 74 ms
70,908 KB
testcase_36 AC 84 ms
76,392 KB
testcase_37 AC 104 ms
92,352 KB
testcase_38 AC 138 ms
112,748 KB
testcase_39 AC 108 ms
91,068 KB
testcase_40 AC 83 ms
76,460 KB
testcase_41 AC 97 ms
82,212 KB
testcase_42 AC 88 ms
76,508 KB
testcase_43 AC 73 ms
71,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n, *b = map(int, stdin.read().split())
p = 998244353

def powmod(n,pow,mod):
    val = 1
    while pow > 0:
        if pow & 1:
            val = (val * n) % mod
        pow = pow >> 1
        n = (n * n) % mod
    return val

numof2 = [0 for i in range(n+1)]
val = 2
while val <= n:
    kari = val
    while kari <= n:
        numof2[kari] += 1
        kari += val
    val = val * 2

kaijo = [0 for i in range(n+1)]
for i in range(1,n+1):
    kaijo[i] = kaijo[i-1] + numof2[i]

nowans = 0
oddnum = 0
evennum = 0
for i in range(n):
    kari = kaijo[n-1] - kaijo[i] - kaijo[n-1-i]
    if kari >= 1:
        if b[i] == -1:
            evennum += 1
    else:
        if b[i] == -1:
            oddnum += 1
        else:
            nowans = nowans ^ b[i]

if oddnum == 0:
    if nowans == 0:
        print("{}".format(0))
    else:
        ans = powmod(2,evennum,p)
        print("{}".format(ans))
else:
    ans = powmod(2,evennum+oddnum-1,p)
    print("{}".format(ans))
0