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 ...
随机推荐
- How to export a template in Visual Studio?
Create a customize template file: 1.template arguments introduction like: 上图只是其中一部分,更多请查看文后的参考资源 tem ...
- csuoj 1337: 搞笑版费马大定理
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1337 1337: 搞笑版费马大定理 Time Limit: 1 Sec Memory Limit ...
- C++之路进阶——codevs2404(糖果)
2404 糖果 2011年省队选拔赛四川 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 幼儿园里有N个小朋友,l ...
- CCF真题之最优灌溉
201412-4 问题描述 雷雷承包了很多片麦田,为了灌溉这些麦田,雷雷在第一个麦田挖了一口很深的水井,所有的麦田都从这口井来引水灌溉. 为了灌溉,雷雷需要建立一些水渠,以连接水井和麦田,雷雷也可以利 ...
- exec 临时表,报错
因为零时表只存在于一个exec 会话中,所以可以用 多个 select 返回到 dataset 中处理多个table,按照select 的顺序,读取 tables[0],table[1] , 多用于统 ...
- paper 73 :HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像
HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像.国内的教程基本语焉不详,找到一篇比较详尽的国外教程翻译出来,希望对大家有帮助.^_^ 原文地址:http://p ...
- 9. 星际争霸之php设计模式--代理模式
题记==============================================================================本php设计模式专辑来源于博客(jymo ...
- 【py技巧】使用reload重导入修改过的包或模块
#使用import导入 import my_module my_module.something() #out - orignal #这里修改输出 - changed reload(my_module ...
- SQL SERVER2012秘钥
来自网络: MICROSOFT SQL SERVER 2012 DEVELOPER 版(开发版)序列号:YQWTX-G8T4R-QW4XX-BVH62-GP68YMICROSOFT SQL SERVE ...
- 视频处理控件TVideoGrabber如何重新编码视频/音频(2)
在前面的文中<视频处理控件TVideoGrabber如何重新编码视频>已经讲解了部分TVideoGrabber重新编码音频.视频剪辑的内容,下面将继续说明. 重新编码进程 重新编码开始时, ...