結果

問題 No.1049 Zero (Exhaust)
ユーザー Yagnik sakhiyaYagnik sakhiya
提出日時 2020-05-09 22:10:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 163,376 KB
実行使用メモリ 11,184 KB
最終ジャッジ日時 2023-09-20 09:25:07
合計ジャッジ時間 3,735 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 10 ms
8,700 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 10 ms
7,736 KB
testcase_06 AC 15 ms
11,136 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 6 ms
5,672 KB
testcase_09 AC 12 ms
9,248 KB
testcase_10 AC 13 ms
9,720 KB
testcase_11 AC 12 ms
9,780 KB
testcase_12 AC 14 ms
10,800 KB
testcase_13 AC 5 ms
5,060 KB
testcase_14 AC 8 ms
7,004 KB
testcase_15 AC 11 ms
8,772 KB
testcase_16 AC 9 ms
7,772 KB
testcase_17 AC 10 ms
8,044 KB
testcase_18 AC 13 ms
9,916 KB
testcase_19 AC 11 ms
8,828 KB
testcase_20 AC 6 ms
5,640 KB
testcase_21 AC 11 ms
9,028 KB
testcase_22 AC 8 ms
6,600 KB
testcase_23 AC 15 ms
11,156 KB
testcase_24 AC 15 ms
11,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<int,int>
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 1000005;

void solve()
{    
     ll n,p;
     cin >> p >> n;
     ll dp[n+1];
     dp[0] = 1;
     ll crt = 1;
     ll pre = 0;
     for(ll i=1;i<=n;i++)
     {
          dp[i] = (dp[i-1] * (p+1))%MOD;
          dp[i] = (dp[i] + (2 * pre))%MOD;
          crt = (crt * 2 * p)%MOD;
          pre = (crt - dp[i] + MOD)%MOD;
     }
     cout<<dp[n];
}

int main()
{
     int t = 1;
     //  cin >> t;
     while(t--)
     {    
          solve();
     }
}
0