Not Wool Sequences(CF-239C)

Problem 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 Not Wool Sequences(CF-239C). In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.

The expression Not Wool Sequences(CF-239C) means applying the operation of a bitwise xor to numbers x and 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 n integers 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).

题意:给出 n、m 两个数,现在要在 0~2^m-1 个数中取可重复的 n 个数,使得组成的序列异或和为 0,问这 2^m-1 个数中组成的序列有多少个满足要求

思路:

设一个前缀数组,使得 sum[i]=sum[i-1]^a[i],那么 a[i]=sum[i-1]^sum[i]

假设 0~2^m-1 不是一个满足要求的序列,那么 a[l]^a[l+1]^...^a[r]!=0,即有:sum[l-1]^sum[r]!=0

由于 l<=r,因此 sum 数组中的所有数需要两两不同

又因为 a[i]=sum[i-1]^sum[i],因此 sum[i] 的取值在 [1,2^m]

因此,问题就变成求有多少个长度为 n 的数组,且数组中的数在 [1,2^m] 之间且不相同

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+9;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int main(){
    LL n,m;
    scanf("%lld%lld",&n,&m);
    LL mul=1,res=1;
    for(int i=1;i<=m;i++)
        mul=(mul*2)%MOD;
    for(int i=1;i<=n;i++)
        res=(res*(mul-i))%MOD;
    printf("%lld\n",res);
	return 0;
}

 

上一篇:Binary Number(位运算)


下一篇:C++整数