日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Not Wool Sequences(CF-239C)

發布時間:2025/3/17 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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; }

?

總結

以上是生活随笔為你收集整理的Not Wool Sequences(CF-239C)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。