题目很简单。

给你n个数,输出n个答案,第i个答案表示从n个数里取遍i个数的异或值的和。

其实每一个数最多也就32位,把所有的数分解,保存每一位总共有多少个1,最后要是这一位的异或结果为1,那么在所有的异或数中,这一位为1的数必须是有奇数个,在求解的时候就是求组合数的情况就可以了。

直接水过。

#include <iostream>
#include <cstdio>
#include <cstring>
#define M 1000003
#define maxn 1005
typedef long long ll;
using namespace std; int a[];
int ans,n,m,k,c[maxn][maxn],u[];
ll tep; void insert(int x)
{
for (int cur=; x; cur++,x>>=) a[cur]+=x&;
} void init_c()
{
u[]=;
for (int i=; i<=; i++) u[i]=(u[i-]+u[i-])%M;
c[][]=;
c[][]=c[][]=;
for (int i=; i<maxn; i++)
{
c[i][]=;
for (int j=; j<=i; j++)
c[i][j]=(c[i-][j]+c[i-][j-])%M;
}
} int main()
{
init_c();
while (scanf("%d",&n)!=EOF)
{
memset(a,,sizeof a);
for (int i=; i<=n; i++) scanf("%d",&k),insert(k);
for (int i=; i<=n; i++)
{
ans=;
for (int j=; j<=; j++)//每一位为1的情况
{
for (k=; k<=a[j] && k<=i; k+=)
{
if (i-k>n-a[j]) continue;
tep=(ll)c[a[j]][k]*c[n-a[j]][i-k];
tep%=M;
tep=(tep*u[j])%M;
ans+=tep;
if (ans>=M) ans-=M;
}
}
if (i>) printf(" ");
printf("%d",ans);
}
printf("\n");
}
return ;
}

HDU4810_Wall Painting的更多相关文章

  1. CF448C Painting Fence (分治递归)

    Codeforces Round #256 (Div. 2) C C. Painting Fence time limit per test 1 second memory limit per tes ...

  2. [译]使用Continuous painting mode来分析页面的绘制状态

    Chrome Canary(Chrome “金丝雀版本”)目前已经支持Continuous painting mode,用于分析页面性能.这篇文章将会介绍怎么才能页面在绘制过程中找到问题和怎么利用这个 ...

  3. Codeforces Round #353 (Div. 2)Restoring Painting

    Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was sto ...

  4. hdu-4810 Wall Painting(组合数学)

    题目链接: Wall Painting Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  5. Codeforces Gym 100342C Problem C. Painting Cottages 转化题意

    Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

  6. F面经:painting house

    There are a row of houses, each house can be painted with three colors red, blue and green. The cost ...

  7. HDU 3685 Rotational Painting(多边形质心+凸包)(2010 Asia Hangzhou Regional Contest)

    Problem Description Josh Lyman is a gifted painter. One of his great works is a glass painting. He c ...

  8. HDU 4810 Wall Painting

    Wall Painting Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  9. UVA 253 Cube painting(暴力打表)

    Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...

随机推荐

  1. 20155329胡佩伦《Java程序设计》第2周学习总结

    学号 20155329 <Java程序设计>第2周学习总结 教材学习内容总结 基本类型 整数(short.int.long) 字节(byte) 浮点数(float/double) 字符(c ...

  2. 3060 抓住那头奶牛 USACO

    3060 抓住那头奶牛 USACO 时间限制: 1 s 空间限制: 16000 KB 题目等级 : 黄金 Gold 题目描述 Description 农夫约翰被告知一头逃跑奶牛的位置,想要立即抓住它, ...

  3. 解读python手册的例子a, b = b, a+b

    Python手册上有个例子,用于输出10以内的斐波那契序列.代码如下: a, b = 0, 1 while b < 10: print(b) a, b = b, a+b 用到了一些Python的 ...

  4. cogs1341 永无乡

    cogs1341 永无乡 打了一发替罪羊树. 鬼故事:替罪羊树去掉重构(变成裸的二叉排序树)依然跑得过= = 启发式合并.每次把小的里面所有东西往大的里面一丢,每个点最多被丢\(log_2n\)次(丢 ...

  5. django中的路由控制详解

    一 Django中路由的作用 二 简单的路由配置 三 有名分组 四 路由分发 五 反向解析 六 名称空间 七 django2.0版的path 一 Django中路由的作用 URL配置(URLconf) ...

  6. Hibernate各种主键生成策略与配置详解(转)

    原文链接:http://www.cnblogs.com/hoobey/p/5508992.html 1.assigned 主键由外部程序负责生成,在 save() 之前必须指定一个.Hibernate ...

  7. appium+python自动化☞appium python api大全

    整理了一些常用的appium python api,供学习使用...

  8. [SHELL]查看端口,文件,服务关系的四个命令netstat,lsof,fuser,nmap

    一,netstat (1)简介 netstat主要是用来打印系统网络的状态信息,当输入netstat后,输出如下: 可以看出,netstat的输出分为两个部分组成: 一个是Active Interne ...

  9. 如何停止AAD服务

    Connect-MsolService (Get-MSOLCompanyInformation).DirectorySynchronizationEnabled 用这个命令查看是enable还是Dis ...

  10. Python异常(基础) except

    为什么要异常处理机制:在程序调用层数较深时,向主调函数传递错误信息需要层层return 返回比较麻烦,用异常处理机制可以较简单的传送错误信息 什么是错误 错误是指由于逻辑或语法等导致一个程序已无法正常 ...