HDU 4810 Wall Painting
Wall Painting
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1026 Accepted Submission(s):
280
Funny Wall) every day. Every day before painting, she produces a wonderful color
of pigments by mixing water and some bags of pigments. On the K-th day, she will
select K specific bags of pigments and mix them to get a color of pigments which
she will use that day. When she mixes a bag of pigments with color A and a bag
of pigments with color B, she will get pigments with color A xor B.
When she
mixes two bags of pigments with the same color, she will get color zero for some
strange reasons. Now, her husband Mr.Fang has no idea about which K bags of
pigments Ms.Fang will select on the K-th day. He wonders the sum of the colors
Ms.Fang will get with
differentplans.
For example, assume n = 3, K = 2 and three bags of pigments with
color 2, 1, 2. She can get color 3, 3, 0 with 3 different plans. In this
instance, the answer Mr.Fang wants to get on the second day is 3 + 3 + 0 =
6.
Mr.Fang is so busy that he doesn’t want to spend too much time on it. Can
you help him?
You should tell Mr.Fang the answer from the first day to the
n-th day.
EOF.
For each test case, the first line contains a single integer N(1 <= N
<= 103).The second line contains N integers. The i-th integer
represents the color of the pigments in the i-th bag.
representing the answers(mod 106 +3) from the first day to the n-th
day.
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef __int64 LL; const LL p = 1e6+;
int a[];
LL cnm[][];
LL hxl[]; void Init()
{
for(int i=;i<=;i++)
{
cnm[i][i]= ;
cnm[i][]= i;
cnm[i][]=;
}
cnm[][]=;
for(int i=;i<=;i++)
{
for(int j=;j<=i;j++)
{
if(i==j)cnm[i][j]=;
else if(j==) cnm[i][j]=i;
else cnm[i][j] = (cnm[i-][j]+cnm[i-][j-])%p;
}
}
hxl[]=;
for(int i=;i<=;i++)
hxl[i]=(hxl[i-]*)%p;
}
int main()
{
Init();
int n;
LL x;
while(scanf("%d",&n)>)
{
if(n==)
{
scanf("%I64d",&x);
printf("%I64d\n",x%p);
continue;
}
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
scanf("%I64d",&x);
int len = ;
while(x)
{
++len;
a[len] = a[len]+(x&);
x=x>>;
}
}
LL sum ;
for(int m=;m<=n;m++)//枚举一次取几个数字
{
sum = ;
for(int j=;j<=;j++)//枚举每一个位
{
for(int i=;i<=a[j]&&i<=m;i=i+)//每一位上取1的个数
{
//if(cnm[n-a[j]][m-i])
sum = (sum+(hxl[j]*(cnm[a[j]][i]*cnm[n-a[j]][m-i])%p)%p)%p;
}
}
printf("%I64d",sum);
if(m!=n) printf(" ");
else printf("\n");
}
}
return ;
}
HDU 4810 Wall Painting的更多相关文章
- hdu 4810 Wall Painting (组合数+分类数位统计)
Wall Painting Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 4810 Wall Painting (组合数学+二进制)
题目链接 下午比赛的时候没有想出来,其实就是int型的数分为30个位,然后按照位来排列枚举. 题意:求n个数里面,取i个数异或的所有组合的和,i取1~n 分析: 将n个数拆成30位2进制,由于每个二进 ...
- HDU - 4810 - Wall Painting (位运算 + 数学)
题意: 从给出的颜料中选出天数个,第一天选一个,第二天选二个... 例如:第二天从4个中选出两个,把这两个进行异或运算(xor)计入结果 对于每一天输出所有异或的和 $\sum_{i=1}^nC_{n ...
- hdu-4810 Wall Painting(组合数学)
题目链接: Wall Painting Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu 1348 Wall(凸包模板题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 Wall Time Limit: 2000/1000 MS (Java/Others) M ...
- POJ 1113 || HDU 1348: wall(凸包问题)
传送门: POJ:点击打开链接 HDU:点击打开链接 以下是POJ上的题: Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissio ...
- hdu 1348 Wall (凸包)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 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 ...
- hdu 1348:Wall(计算几何,求凸包周长)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
随机推荐
- Codeforce Round #211 Div2
真的是b到不行啊! 尼玛C题一个这么简单的题目没出 aabbccddee 正确的是aabccdee 我的是 aabcdee 硬是TM的不够用,想半天还以为自己的是对的... A:题... B:题. ...
- C#: enum
C#的枚举类型跟C++差不多,一般我们将enum设为单个状态,比如enum color_t { RED, BLACK, GREEN}, 只能选择一个 而有的时候枚举可以作为位运算来进行与或运算,比如C ...
- bzoj4137 [FJOI2015]火星商店问题
比较容易想到的做法是线段树套字典树,修改操作时在字典树上经过的节点维护一个最近被访问过的时间,这样询问操作只经过满足时间条件的节点,时间复杂度O(NlogN^2)但是因为线段树每个节点都要套个字典树, ...
- struts_19_对Action中所有方法、某一个方法进行输入校验(手工编写代码实现输入校验)
对所有方法进行校验1.通过手工编写代码的形式实现 需求:用户名:不能为空手机号:不能为空,并且要符合手机号的格式1,3/5/8,后面是9个数字 第01步:导包 第02步:配置web.xml <? ...
- 转:MyEclipse8.6插件安装方法
通常,我们可以用update来直接安装.但是myeclipse限制了中国区的下载和更新.所以我们只能用插件配置的方法来实现. MyEclipse8.6插件安装同Eclipse插件安装方式大致相同,如下 ...
- C语言初学者代码中的常见错误与瑕疵(1)
曾在豆瓣上看到过一个小朋友贴出他自己的代码(http://www.douban.com/group/topic/40293109/),当时随口指点了几句.难得这位小朋友虚心修正.从善如流,不断地改,又 ...
- IIS、Asp.net 编译时的临时文件路径(转载)
IIS上部署的ASP.NET站点都会在一个.Net Framework的特定目录下生成临时编译文件增加ASP.NET站点的访问性能,有时候需要手动去删除这些临时编译文件,特别是发布新版本代码到IIS后 ...
- WM_SETFOCUS和WM_KILLFOCUS、WM_GETDLGCODE、CM_ENTER...
procedure WMSetFocus (var Message: TWMSetFocus); message WM_SETFOCUS; //获得焦点 procedure WMKillFocus ( ...
- linux 安装
分区:/boot swap /这三个顺序分区 mkdir -p|-m cat >> 123.txt<<EOF 123 345 EOF 0.1和2分别表示标准输入.标准输出和标准 ...
- 一篇文章一张思维导图看懂Android学习最佳路线
一篇文章一张思维导图看懂Android学习最佳路线 先上一张android开发知识点学习路线图思维导图 Android学习路线从4个阶段来对Android的学习过程做一个全面的分析:Android初级 ...