Codeforces 239C Not Wool Sequences【规律】

来源:互联网 发布:网络词w . f是什么意思 编辑:程序博客网 时间:2024/06/05 16:13

C. Not Wool Sequences
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 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的一个序列,其中元素只能是0~2^m-1;

构造出来的序列需要保证任意区间内的亦或值不能为0.;


思路:


暴力打表找找规律就行了。

不难发现其如果n==1的时候,结果就是2^m-1;

如果n>1的时候,是随着n的递增,而成倍数递增的。

具体规律参考一下代码就行了。


Ac代码:

#include<stdio.h>#include<string.h>using namespace std;__int64 mod=1000000009;__int64 mi(__int64 a,__int64 b){    __int64 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(){    int n,m;    while(~scanf("%d%d",&n,&m))    {        __int64 ans=mi(2,m);        ans-=1;        __int64 temp=ans-1;        ans=(ans%mod+mod)%mod;        temp=(temp%mod+mod)%mod;        for(int i=2;i<=n;i++)        {            ans*=temp;            ans%=mod;            temp--;            temp=(temp%mod+mod)%mod;        }        printf("%I64d\n",ans%mod);    }}