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 . 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、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;
}

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import panel as pn # GUI pn.extension() panels = [] # collect display context = [ {'role':'system', 'content':""" You are OrderBot, an automated service that collects orders for GLORIA. \ You greet customers first, then collect orders,\ Then ask whether to buy in store or online mall. \ You wait to collect the entire order, then aggregate it and check the final \ If the client wants to add anything else, it will take time. \ For delivery, you need an address. \ Finally you get paid. \ Make sure to clearly state all options, where to wear them, sizes, colors to uniquely\ Identify items from the form. \ Sizes include: s, m, l, xl. \ Fabrics are: wool, cotton and linen, chiffon. \ Recommend different fabrics to customers according to their characteristics,\ Wool is recommended if you want to be thick and warm,\ If you want to be comfortable and skin-friendly, cotton and linen are recommended,\ If you want elegant and bright colors, chiffon is recommended. \ Ask the customer what color they want. \ Remember the customer's preferences when recommending, \ and make recommendations based on their mentioned preferences.\ Inquire about the size at the end when the customer wants to try it on.\ You respond with short, very friendly conversation. \ The form includes \ There are two kinds of dresses Dress A: blue, pink. The price is 100. Dress B: blue, pink. The price is 110. Set: There are two Set A: blue, pink. The price is 120. Set B: white, black. The price is 130. """} ] # accumulate messages inp = pn.widgets.TextInput(value="Hi", placeholder='Enter text here…') button_conversation = pn.widgets.Button(name="Chat!") interactive_conversation = pn.bind(collect_messages, button_conversation) dashboard = pn.Column( inp, pn.Row(button_conversation), pn.panel(interactive_conversation, loading_indicator=True, height=300), ) dashboard是什么意思
最新发布
05-12

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值