結果

問題 No.1049 Zero (Exhaust)
ユーザー uni_pythonuni_python
提出日時 2020-06-21 12:27:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 147,696 KB
最終ジャッジ日時 2023-09-16 18:16:31
合計ジャッジ時間 5,669 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,088 KB
testcase_01 AC 74 ms
71,488 KB
testcase_02 AC 74 ms
71,572 KB
testcase_03 AC 171 ms
121,672 KB
testcase_04 AC 74 ms
71,376 KB
testcase_05 AC 169 ms
120,776 KB
testcase_06 AC 209 ms
147,696 KB
testcase_07 AC 85 ms
77,024 KB
testcase_08 AC 116 ms
94,564 KB
testcase_09 AC 165 ms
122,456 KB
testcase_10 AC 198 ms
146,428 KB
testcase_11 AC 202 ms
146,244 KB
testcase_12 AC 206 ms
147,148 KB
testcase_13 AC 110 ms
94,080 KB
testcase_14 AC 122 ms
95,536 KB
testcase_15 AC 163 ms
122,180 KB
testcase_16 AC 158 ms
120,920 KB
testcase_17 AC 157 ms
121,012 KB
testcase_18 AC 203 ms
146,296 KB
testcase_19 AC 167 ms
121,896 KB
testcase_20 AC 116 ms
94,748 KB
testcase_21 AC 165 ms
122,176 KB
testcase_22 AC 118 ms
95,496 KB
testcase_23 AC 204 ms
147,652 KB
testcase_24 AC 207 ms
147,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    P,K=MI()
    dp=[[0,0]for _ in range(K+1)]
    #i回操作して,Nが0or非0の通り数
    dp[0][0]=1
    
    for i in range(K):
        dp[i+1][0]=(dp[i][0]*(P+1) + dp[i][1]*2)%mod
        dp[i+1][1]=(dp[i][0]*(P-1) + dp[i][1]*(2*P-2))%mod
        
    print(dp[-1][0])
    
    
main()
0