zoukankan      html  css  js  c++  java
  • hdu 6129(Just do it)

    题目链接:Just do it

    题目意思:

    给你a数组,n个数。每次操作是(b_i = a_1 wedge a_2 wedge a_3 cdots a_{i-1} wedge a_i),再把b数组的数复制到a数组;重复进行m次。问最后b数组的数字,输出他。over

    思路:

    写下,下图。发现 每次操作中,都是左边的+上面的,和杨辉三角很像。

    进一步,得到a1的系数矩阵

    a2的系数矩阵

    我们发现(a_n) 的系数矩阵就是把(a_1)的系数矩阵往右移对应次数。因为系数为奇数才会有贡献,所以判断(C_n^m)为奇数,(a_1,a_2cdots a_n)的系数矩阵才为奇数,为答案贡献一次。

    #include <stdio.h>
    #include <string.h>
    
    const int maxn=2e5+100;
    int a[maxn],b[maxn];
    int main()
    {
        int ncase;
        scanf("%d",&ncase);
        while(ncase--)
        {
            int n,m;
            scanf("%d%d",&n,&m);
            memset(b,0,sizeof(b));
            for(int i=1;i<=n;i++) scanf("%d",&a[i]);
            for(int i=1;i<=n;i++)
            {
                int x=i-1;
                int y=i+m-2;
                if((x&y)==x) for(int j=i;j<=n;j++) b[j]^=a[j-i+1];
            }
            for(int i=1;i<=n;i++) printf(i==n?"%d
    ":"%d ",b[i]);
        }
        return 0;
    }
    
  • 相关阅读:
    svn不提交.net项目中的bin
    java 与C# 时间格式 交互
    生成菜单序列号
    ashx 方法模板
    webservice使用方法
    如何配置IIS服务器?
    zepto.fullpage
    模拟单选框
    star score
    Hover show tips
  • 原文地址:https://www.cnblogs.com/coded-ream/p/7379829.html
Copyright © 2011-2022 走看看