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 ...
随机推荐
- 转:python webdriver API 之定位一组对象
webdriver 可以很方便的使用 find_element 方法来定位某个特定的对象,不过有时候我们却需要定位一组对象,WebElement 接口同样提供了定位一组元素的方法 find_eleme ...
- UVa 10088 - Trees on My Island (pick定理)
样例: 输入:123 16 39 28 49 69 98 96 55 84 43 51 3121000 10002000 10004000 20006000 10008000 30008000 800 ...
- 搜集好的java技术帖子,持续更新,java程序员的要求
1.Java NIO 系列教程 2.Java实现 二叉搜索树算法(BST) 3. Java 并发工具包 java.util.concurrent 用户指南 4.架构师之路系列:http://blog. ...
- Java基础(42):Java中主类中定义方法加static和不加static的区别(前者可以省略类名直接在主方法调用,后者必须先实例化后用实例调用)
package lsg.ap.april4th2; /* 知识点:1.Getter and Setter 的应用 2.局部变量与成员变量(也可叫做全局变量) 3.Static关键字的用法 a.成员变量 ...
- paper 71 :图像清晰化
图像清晰度是衡量图像品质优劣的标准之一,清晰的图像能给人以赏心悦目的视觉享受.长期以来,图像扫描设备和图像处理软件的开发生产厂商都很重视图像清晰度处理功能的开发,图像处理人员也在日常的实践中不断摸索出 ...
- Mysql触发器总结
触发器(trigger):监视某种情况,并触发某种操作. 触发器创建语法四要素:1.监视地点(table) 2.监视事件(insert/update/delete) 3.触发时间(after/befo ...
- word - 如何让 图片任意移动
选中图片, 设置图片的自动换行 为四周环绕型
- [CrunchBang]禁止“桌面上鼠标滚轮切换工作区桌面“
鼠标滚轮切换虚拟桌面相关问题, 编辑 ~/.config/openbox/rc.xml 在 <context name="Desktop">段: <mouse ...
- js表单提交一种方式
在一个html和php混编的文件中,用到js提交表单的方法: 定义表单id为form1,提交按钮type为submit, var data_info = document.getElementById ...
- SQL关于apply的两种形式cross apply和outer apply(转载)
SQL 关于apply的两种形式cross apply 和 outer apply apply有两种形式: cross apply 和 outer apply 先看看语法: <lef ...