Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Problem Description
During summer vacation,Alice stay at home for a long time, with nothing to do. She went out and bought m pokers, tending to play poker. But she hated the traditional gameplay. She wants to change. She puts these pokers face down, she decided to flip poker n times, and each time she can flip Xi pokers. She wanted to know how many the results does she get. Can you help her solve this problem?
Input
The input consists of multiple test cases.
Each test case begins with a line containing two non-negative integers n and m(0
Output
Output the required answer modulo 1000000009 for each test case, one per line.
Sample Input
3 43 2 33 33 2 3
Sample Output
83
Hint
For the second example:0 express face down,1 express face upInitial state 000The first result:000->111->001->110The second result:000->111->100->011The third result:000->111->010->101So, there are three kinds of results(110,011,101)
區間維護很繞人!!!!!前面把它想簡單了,無限跪!!
還有組合數快速冪求模,以前都沒記這東西!!!
按題解在賽後總算把它A了!
AC代碼如下:
#include#include #include #define mod 1000000009 #define ll long long #define M 100005 using namespace std; ll n,m; ll a[M],c[M]; ll pow_mod(ll a,ll b) { ll s=1; while(b) { if(b&1)s=s*a%mod; a=a*a%mod; b=b>>1; } return s; } int main() { ll i,j; ll ans,minn,maxx; while(~scanf("%lld%lld",&n,&m)) { ans=0; ll l=0,r=0; for(i=0;i =0)//左區間的改變 minn=l-a[i]; else if(r-a[i]>=0) minn=((l+a[i])&1)?1:0; else minn=a[i]-r; l=minn;r=maxx; } //cout<