题目很简单。

给你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. week8课上实践

    课上练习. 第一题: 参考 http://www.cnblogs.com/rocedu/p/6766748.html#SECCLA 在Linux下完成"求命令行传入整数参数的和" ...

  2. C#基础之Equals和Dispose

    1.equal()和运算符==的区别 由于C#中有值类型和引用类型,那么相等也分为值相等和引用相等.先来看一个值类型简单的例子,顺便也写了string类型的比较. static void Main(s ...

  3. resultMap中的collection集合出现只能读取一条数据的解决方法

    查询数据时只能获得collection集合中的的一条数据,相关情况如下: 结果集resultMap: <resultMap id="ManagerRolesAcls" typ ...

  4. SRM 653 CountryGroupHard

    SRM 653 CountryGroupHard 题意: n 个人坐成一排,同一个国家的人坐在一起,记者问了一些人他们的国家有多少人,他们都回答了正确的信息.已知m条信息,每条信息形如第 pi 个位置 ...

  5. java程序运行中如果出现异常未被处理,将会被抛到java虚拟机进行处理,程序中断运行后被挂起,在页面输出错误信息(不会输出到console)

    下面的代码中,因为我是使用 for (Iterator<Element> i = el.elements().iterator(); i.hasNext(); ) 迭代器遍历根节点的所有子 ...

  6. hdu2061 Treasure the new start, freshmen!(暴力简单题)

    Treasure the new start, freshmen! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  7. Git生成SSH密钥

    git config --global user.name "yangjianliang"配置用户名 git config --global user.email "52 ...

  8. shell 判断日期间隔及润年

    #!/bin/bash test.sh until echo "----------------------------------" echo "请输入您的选择:&qu ...

  9. WebGL中使用window.requestAnimationFrame创建主循环

    今天总结记录一下WebGL中主循环的创建和作用.我先说明什么是主循环,其实单纯的webgl不存在主循环这个概念,这个概念是由渲染引擎引入的,主循环就是利用一个死循环或无截止条件的递归达到定时刷新can ...

  10. JY播放器【网易云音乐破解下载】

    今天给大家带来一款神器----JY播放器.可以直接下载网易云音乐的歌曲. 目前已经支持平台(蜻蜓FM.喜马拉雅FM.网易云音乐.QQ音乐) 使用方法: 在电脑打开网易云音乐或者网站找到你要听的歌曲或歌 ...