結果
| 問題 |
No.2060 AND Sequence
|
| コンテスト | |
| ユーザー |
taiga0629kyopro
|
| 提出日時 | 2022-08-06 01:17:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,057 bytes |
| コンパイル時間 | 391 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 54,272 KB |
| 最終ジャッジ日時 | 2024-09-19 02:14:32 |
| 合計ジャッジ時間 | 3,241 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 43 |
ソースコード
def naive (n,m):
mod=998244353
dp=[[0]*(m+1) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
for x in range(m+1):
for y in range(m+1):
if x&y==y:
dp[i][x]+=dp[i-1][y]
dp[i][x]%=mod
return sum(dp[n])%mod
def sol1(n,m):
mod=998244353
memo=dict()
def dp(m,k,f):
if m==0:
if k==0 and f==1:return 1
return 0
if (m,k,f) in memo:return memo[m,k,f]
ans=0
for bx in range(2):
nf=f
if nf==0 and m%2==1 and bx==0:nf=1
if nf==1 and m%2==0 and bx==1:nf=0
ans+=dp(m//2,k-bx,nf)
ans%=mod
memo[m,k,f]=ans
return ans
ans=0
for k in range(33):
ans+=dp(m,k,1)*pow(n,k,mod)%mod
ans%=mod
return ans
from random import randrange as rd
cnt=0
while 0:
cnt+=1
print(cnt)
n=rd(2,1000)
m=rd(1,1000)
ans1=naive(n,m)
ans2=sol1(n,m)
if ans1!=ans2:
print(n,m)
break
taiga0629kyopro