# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20190 | 2016-03-02T15:10:47 Z | rlatnwls | 괄호 (kriii4_R) | C++ | 0 ms | 0 KB |
#include cstdio> const long long mod = 1000000007; long long t1[1000002],c[1000002]; int main() { int n,k; scanf ("%d %d",&n,&k); t1[1] = 1; for (int i=2;i<=n/2+1;i++) t1[i] = (1 - 1 / i) * t1[i] % mod; //catalan에서 1/n+1부분?? c[0] = 1; for (int i=1;i<=n/2;i++) c[i] = 2*(2 * i - 1) * t1[i+1] % mod * c[i-1] % mod;//전의 c[i-1]에서 곱할 계수? long long u = 1; for (int i=1;i<=n/2;i++){ u = u * k % mod; c[i] = c[i] * u % mod; }//k^n/2부분?? long long res = 1ll; for (int i=0;i<n;i++){ res = res * (k + 1) % mod; if (i % 2 == 0) res = (res - c[i/2]) % mod; } printf ("%lld\n",res); return 0; }