結果

問題 No.1049 Zero (Exhaust)
ユーザー auauaauaua
提出日時 2020-05-08 21:51:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 169,212 KB
実行使用メモリ 57,916 KB
最終ジャッジ日時 2023-09-17 02:36:10
合計ジャッジ時間 3,880 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 63 ms
40,368 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 53 ms
33,296 KB
testcase_06 AC 92 ms
57,916 KB
testcase_07 AC 14 ms
10,200 KB
testcase_08 AC 29 ms
19,072 KB
testcase_09 AC 69 ms
44,072 KB
testcase_10 AC 75 ms
47,556 KB
testcase_11 AC 75 ms
47,880 KB
testcase_12 AC 88 ms
54,928 KB
testcase_13 AC 22 ms
14,648 KB
testcase_14 AC 41 ms
26,268 KB
testcase_15 AC 65 ms
41,236 KB
testcase_16 AC 52 ms
33,760 KB
testcase_17 AC 57 ms
35,468 KB
testcase_18 AC 77 ms
48,644 KB
testcase_19 AC 66 ms
41,368 KB
testcase_20 AC 29 ms
18,772 KB
testcase_21 AC 67 ms
42,668 KB
testcase_22 AC 39 ms
25,252 KB
testcase_23 AC 92 ms
57,800 KB
testcase_24 AC 91 ms
57,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll p,k;cin>>p>>k;
    vector<vector<ll> >dp(k+1,vector<ll>(2));
    dp[0][0]=1;
    rep(i,k){
        dp[i+1][1]=(dp[i+1][1]+dp[i][0]*(p-1)%mod)%mod;
        dp[i+1][0]=(dp[i+1][0]+dp[i][0]*(p+1)%mod)%mod;
        dp[i+1][0]=(dp[i+1][0]+dp[i][1]*(2)%mod)%mod;
        dp[i+1][1]=(dp[i+1][1]+dp[i][1]*(2*p-2)%mod)%mod;
    }
    cout<<dp[k][0]<<endl;
}
0