-
Notifications
You must be signed in to change notification settings - Fork 1
/
power.cpp
54 lines (45 loc) · 1.09 KB
/
power.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
#define FOR(i, n) for(int i=0;i<int(n);i++)
#define FOR1(i, n) for(int i=1;i<=int(n);i++)
#define FORA(i, a, n) for(int i=a;i<int(n);i++)
#define foreach(it, c) for(typeof(c.begin()) it = c.begin(); it != c.end(); it++)
typedef long long int lli;
typedef pair<int,int> ii;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
const int MOD = 1000000007;
const int N = 1010;
int C[N][N];
int power(int a, int k){
if(k == 0) return 1;
lli ret = power(a,k/2);
ret *= ret, ret %= MOD;
return (ret * (k % 2 ? a : 1)) % MOD;
}
int main()
{
ios::sync_with_stdio(false);
C[0][0] = 1;
FOR1(i,1000) {
C[i][0] = 1;
FOR1(j,i) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
}
FOR(n,1000){
int sum = 0;
FOR(k,n+1) sum += C[n][k], sum %= MOD;
assert(sum == power(2,n));
}
return 0;
}