結果

問題 No.1049 Zero (Exhaust)
ユーザー kyoprounokyoprouno
提出日時 2020-05-08 22:52:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 3,728 ms
コンパイル使用メモリ 176,012 KB
実行使用メモリ 18,676 KB
最終ジャッジ日時 2023-09-17 03:19:58
合計ジャッジ時間 2,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 11 ms
13,588 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 11 ms
11,668 KB
testcase_06 AC 16 ms
18,676 KB
testcase_07 AC 3 ms
5,020 KB
testcase_08 AC 7 ms
7,588 KB
testcase_09 AC 13 ms
14,784 KB
testcase_10 AC 12 ms
16,028 KB
testcase_11 AC 13 ms
16,100 KB
testcase_12 AC 15 ms
17,688 KB
testcase_13 AC 5 ms
6,476 KB
testcase_14 AC 9 ms
9,524 KB
testcase_15 AC 11 ms
13,892 KB
testcase_16 AC 10 ms
11,888 KB
testcase_17 AC 10 ms
12,288 KB
testcase_18 AC 13 ms
16,088 KB
testcase_19 AC 11 ms
14,052 KB
testcase_20 AC 7 ms
7,524 KB
testcase_21 AC 13 ms
14,512 KB
testcase_22 AC 8 ms
9,372 KB
testcase_23 AC 16 ms
18,604 KB
testcase_24 AC 16 ms
18,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll mod=1e9+7;

int main(){
    ll p,k;
    cin >> p >> k;
    vector<ll> dp(k+1);
    vector<ll> all(k);
    ll val=1;
    rep(i,k){
        all[i]=val;
        val*=2*p;
        val%=mod;
    }
    dp[0]=1;
    rep(i,k){
        dp[i+1]=(all[i]-dp[i])*2+dp[i]*(p+1);
        dp[i+1]%=mod;
    }
    cout << dp[k] << endl;
    return 0;
} 
0