# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20044 |
2016-02-25T08:51:29 Z |
noeffserv |
괄호 (kriii4_R) |
C++ |
|
16 ms |
25160 KB |
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#define ENP printf("**Entry Point**\n")
#define A first
#define B second
#define MP make_pair
using namespace std;
typedef long long ll;
typedef vector <double> vec_d;
typedef vector <vec_d> vvec_d;
typedef vector <int> vec_i;
typedef vector <vec_i> vvec_i;
typedef pair <int, int> pair_i;
typedef pair < pair_i, pair_i > pp_i;
const int INF = 0x60000000;
const int MINF = -1000000000;
const ll mod = 1000000007;
const int cons = 50000001;
ll dp2[1000001];
ll dp[1000001][2];
int main()
{
int n;
ll k;
scanf("%d%lld", &n, &k);
dp2[0] = 1;
for (int i = 0; i <= n; i++)
{
dp2[i + 1] = (k*(((4 * ((ll)i) + 2)*dp2[i] / (((ll)i) + 2))%mod))%mod;
}
dp[0][0] = 1;
dp[1][1] = k;
for (int i = 2; i <= n; i++)
{
if (i % 2 == 0)
{
dp[i][0] = dp2[i/2];
dp[i][1] = (dp[i - 1][0] * k + dp[i - 1][1] * k + dp[i - 2][1] * k) % mod;
}
else
{
dp[i][1] = (dp[i - 1][0] * k + dp[i - 1][1] * k + dp[i - 2][1] * k) % mod;
if ((i / 2) % 2 == 0)
{
dp[i][1] = (dp[i][1] + dp[i / 2][1] * k) % mod;
}
}
}
printf("%lld\n", (dp[n][0] + dp[n][1])%mod);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
25160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |