Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // d.cpp -- d
- //
- // Siwakorn Sriakaokul - ping128
- // Written on Saturday, 27 April 2013.
- //
- #include <cstdio>
- #include <iostream>
- #include <sstream>
- #include <cstdlib>
- #include <string>
- #include <vector>
- #include <set>
- #include <queue>
- #include <stack>
- #include <list>
- #include <cmath>
- #include <algorithm>
- #include <map>
- #include <ctype.h>
- #define MOD 1000000009
- using namespace std;
- typedef long long LL;
- LL pow2(int x){
- if(x == 0) return 1LL;
- if(x % 2){
- return (2 * pow2(x - 1)) % MOD;
- } else {
- LL temp = pow2(x / 2);
- return (temp * temp) % MOD;
- }
- }
- LL fac[200005];
- void inverse(LL a, LL b, LL *X, LL *Y){
- if(b == 0){
- *X = 1;
- *Y = 0;
- } else {
- LL xx, yy;
- inverse(b, a % b, &xx, &yy);
- *X = yy;
- *Y = xx - (a / b) * yy;
- }
- }
- LL nCr(LL n, LL r){
- LL x, y;
- inverse((fac[r] * fac[n - r]) % MOD, MOD, &x, &y);
- x = (x + MOD) % MOD;
- return (fac[n] * x) % MOD;
- }
- int main()
- {
- fac[0] = 1;
- for(int i = 1; i < 200005; i++ ){
- fac[i] = (i * fac[i - 1]) % MOD;
- }
- int n;
- cin >> n;
- LL ans = 0;
- for(int i = 1; i < n; i++ ){
- ans += (nCr(n, i) * ((pow2(i) - 1 + MOD) % MOD)) % MOD;
- ans %= MOD;
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement