結果
| 問題 |
No.2097 AND^k
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-08 18:43:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 802 bytes |
| コンパイル時間 | 417 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-10-03 15:09:12 |
| 合計ジャッジ時間 | 3,124 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 1 RE * 22 |
ソースコード
import itertools
MOD = 998244353
def generate_sequences(N, M):
for A in itertools.product(range(2**M), repeat=N):
yield A
def bitwise_and(A):
res = A[0]
for i in range(1, len(A)):
res &= A[i]
return res
def pow_mod(base, exponent, mod):
res = 1
while exponent > 0:
if exponent % 2 == 1:
res = (res * base) % mod
base = (base * base) % mod
exponent //= 2
return res
def main():
N, M, L = map(int, input().split())
sequences = list(generate_sequences(N, M))
for k in range(1, L+1):
total = 0
for A in sequences:
and_result = bitwise_and(A)
total += pow_mod(and_result, k, MOD)
total %= MOD
print(total)
if __name__ == '__main__':
main()