CF239C Not Wool Sequences(找规律+快速幂)

原题网址

  1. 题目大意
    给定n,m两个值,从0~2^m-1中挑选n个数(可重复),使得在以n为长度的序列中,任意子区间中数的异或值都不为0。

  2. 思路
    一开始做的时候,读错题,以为是任意区间的异或值都等于0,发现样例不对,耽误了好久,后来结束后才知道咋回事。
    可以从n=1开始找规律
    n=1:当前区间的子区间只有本身,也就是只要保证本身不为0即可,有2^m-1种;
    n=2:两个数的时候分别来填写,第一个数是n=1时的情况,而第二个数除了0之外,也不能与第一个数相同,因为相同的两个数异或值为0,这样的话第二个数就有2^m-2,和上面的相乘即可
    n=3:由n=2推得前两个数,第三个数除了0,与第二个数相同的数外还要除去第一个数和第二个数的异或值,这样第三个数就有2^m-3,和上面n=2的结果相乘即可
    下面以此类推
    计算2^m-1时直接用快速幂模板即可

  3. 代码`

#include<bits/stdc++.h>
#define mod 1000000009
using namespace std;
int mul(int a,int b,int p)///快速幂模板
{
    int ans=1%p;
    for(; b; b>>=1)
    {
        if(b&1)
            ans=(long long)ans*a%p;
        a=(long long)a*a%p;
    }
    return ans;
}
int main()
{
    int n,m;
    cin>>n>>m;
    long long ans=mul(2,m,mod)-1;
    long long res=1;
    for(int i=0; i<n; i++)
    {
        res=res*ans%mod;
        ans--;
    }
    cout<<res%mod<<endl;
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值