CodeForces - 239C Not Wool Sequences(找规律)

Description:

A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that . In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.

The expression  means applying the operation of a bitwise xor to numbers xand y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is marked as "^", in Pascal — as "xor".

In this problem you are asked to compute the number of sequences made of nintegers from 0 to 2m - 1 that are not a wool sequence. You should print this number modulo 1000000009 (109 + 9).

Input

The only line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 105).

Output

Print the required number of sequences modulo 1000000009 (109 + 9) on the only line of output.

Examples

Input

3 2

Output

6

Note

Sequences of length 3 made of integers 0, 1, 2 and 3 that are not a wool sequence are (1, 3, 1), (1, 2, 1), (2, 1, 2), (2, 3, 2), (3, 1, 3) and (3, 2, 3).

给出0-2^m-1的数,求长度为n的子序列,子序列的数可以由重复,每个数异或后为0这个序列就是羊毛序列,求不是羊毛序列的有多少个,这道题可以先用暴力求出几组解,然后就会发现答案是关于2^m-1的阶乘。

打表的数据:

1 2
3
2 2
6
3 2
6
4 2
0
1 3
7
2 3
42
3 3
210
4 3
840
5 3
2520

AC代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<iomanip>
#include<math.h>
const int INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
typedef double ld;
const int N = 100010;
const int mod = 1000000009;
int i,j,k,l;
int n,m;
int ans;

ll mi(ll a,ll b)
{
    ll ans=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
       scanf("%d %d",&n,&m);
        ll ans=mi(2,m);
        ans--;
        if(n>ans)
        {
            printf("0\n");
            return 0;
        }
        ll res=ans-1;
        ans=(ans%mod+mod)%mod;
        res=(res%mod+mod)%mod;//防止为负数
        for(i=2;i<=n;i++)
        {
            ans*=res;
            ans%=mod;
            res--;
            res=(res%mod+mod)%mod;
        }
        printf("%lld\n",ans%mod);
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值