code forces239c Not Wool Sequences

 

题目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

Copy

3 2

output

Copy

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个数使其组成非羊毛序列(羊毛序列就是存在一个子序列连续异或等于零)问一共有多少种非羊毛序列输出他的种数。

这是一道找规律的题 

1 2 3种

2 2 6种3*2

3 2 6种3*2*1

4 2 0种3*2*1*0

1 3 7种

2 3 42种7*6

3 3 210种7*6*5

4 3 840中7*6*5*4

规律很显然就是阶乘.

#include<string.h>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
long long inf=1e9+9;
int kuai(long long n)
{
    long long nn=1,k=2;
    for(;n;n>>=1)
    {
        if(n&1)
            nn=(long long)nn*k%inf;
        k=(long long)k*k%inf;
    }
    return nn;
}
int main()
{
    long long  n,k,m;
    cin>>n>>m;
    long long ans=kuai(m)-1,cnt=kuai(m);
    for(int i=1;i<=n-1;i++)
    {
        ans=ans*(cnt-1-i)%inf;
    }
    cout<<(ans+inf)%inf<<endl;
}

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值