链接:

https://vjudge.net/problem/HDU-4810

题意:

Ms.Fang loves painting very much. She paints GFW(Great 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 different plans.

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.

思路:

将整数转换为二进制存储,每次对二进制的每一位选择,选择奇数个1,xor出来才有值.

每次组合数枚举可选的整数.

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
//#include <memory.h>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string>
#include <assert.h>
#include <iomanip>
#define MINF 0x3f3f3f3f
using namespace std;
typedef long long LL; const int MAXN = 1e3+10;
const int MOD = 1e6+3;
LL a[MAXN];
LL C[MAXN][MAXN];
LL Num[100];
int n; int main()
{
C[0][0] = 1;
C[1][0] = C[1][1] = 1;
for (int i = 2;i < MAXN;i++)
{
C[i][0] = C[i][i] = 1;
for (int j = 1;j < i;j++)
C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;
}
ios::sync_with_stdio(false);
cin.tie(0);
int t;
while (cin >> n)
{
memset(Num, 0, sizeof(Num));
for (int i = 1;i <= n;i++)
{
LL v;
int cnt = 0;
cin >> v;
while (v)
{
Num[cnt++] += v%2;
v >>= 1;
}
}
for (int i = 1;i <= n;i++)
{
LL res = 0;
for (int j = 31;j >= 0;j--)
{
LL tmp = 0;
for (int k = 1;k <= i;k += 2)
tmp = (tmp + (1LL*C[Num[j]][k]*C[n-Num[j]][i-k])%MOD)%MOD;
res = (res + (1LL*tmp*(1LL<<j))%MOD)%MOD;
}
if (i == n)
cout << res;
else
cout << res << ' ' ;
}
cout << endl;
} return 0;
}

HDU-4810-wall Painting(二进制, 组合数)的更多相关文章

  1. hdu 4810 Wall Painting (组合数+分类数位统计)

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

  2. HDU 4810 Wall Painting

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

  3. hdu 4810 Wall Painting (组合数学+二进制)

    题目链接 下午比赛的时候没有想出来,其实就是int型的数分为30个位,然后按照位来排列枚举. 题意:求n个数里面,取i个数异或的所有组合的和,i取1~n 分析: 将n个数拆成30位2进制,由于每个二进 ...

  4. HDU - 4810 - Wall Painting (位运算 + 数学)

    题意: 从给出的颜料中选出天数个,第一天选一个,第二天选二个... 例如:第二天从4个中选出两个,把这两个进行异或运算(xor)计入结果 对于每一天输出所有异或的和 $\sum_{i=1}^nC_{n ...

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

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

  6. hdu 1348 Wall(凸包模板题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 Wall Time Limit: 2000/1000 MS (Java/Others)    M ...

  7. hdu 5648 DZY Loves Math 组合数+深搜(子集法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5648 题意:给定n,m(1<= n,m <= 15,000),求Σgcd(i|j,i&am ...

  8. POJ 1113 || HDU 1348: wall(凸包问题)

    传送门: POJ:点击打开链接 HDU:点击打开链接 以下是POJ上的题: Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissio ...

  9. HDU 2502 月之数(二进制,规律)

    月之数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

随机推荐

  1. 配置XFCE4的时钟显示格式

    配置XFCE4的时钟显示格式,如下1: %b%d %A, %R:%S 显示结果: 10月09日 星期三,09:50:45 如下2: [%Y年%b %d日] [%A],第%V周,第%j天 显示结果: 2 ...

  2. 替换RTXLogo插件说明

    一.包含Logo图标文件介绍 (一)桌面图标包含在RTX.exe (二)桌面右下角图标包含在MainFrameRes.dll (三)RTX设置图标包含在Config.dll (四)查看用户信息图标包含 ...

  3. php配置 php-cgi.sock使用

    PHP配置文件: [global]pid = /run/php-fpm/php-fpm.piderror_log = /var/log/php-fpm/php-fpm.loglog_level = n ...

  4. oop理论

    三大特性: 封装:把对象的属性和行为独立的一个整体,并尽可能的隐藏对象内部实现细节.增加安全性. 继承:从已有的类中派生出新的类,称为子类,子类继承父类的属性和行为,并能根据自己的需求扩展出新的行为. ...

  5. squid的三种模式

    一.squid代理服务器概述: 概述:Squid Cache(简称为Squid)是http代理服务器软件.Squid用途广泛,可以作为缓存服务器也可以作为缓存代理服务器,代理用户向web服务器请求数据 ...

  6. 【Ruby on Rails 学习五】Ruby语言的方法

    1.方法的调用 2.自定义方法 3.带默认值的自定义方法 4.带返回值的自定义方法 方法或者说是函数,实际上是包含了一段代码,去执行某一个特定的过程. def add(a=3,b=2) return ...

  7. Ubuntu系统挂载磁盘硬盘

    在电脑(Ubuntu16.04)新装了一个硬盘,然后只有挂载了我们才能正常使用,下面总结一下挂载的过程. 首先,打开命令行输入命令: sudo fdisk -l 可以看到:磁盘格式化后 硬盘格式化 命 ...

  8. 【VS开发】解决位图缩放失真

    当用以下函数加载一张位图时,当窗口发生重绘更改大小时,位图将失真: CBitmap bitmap;  bitmap.LoadBitmap(IDB_BITMAP2);  BITMAP bmp;  bit ...

  9. RPCVersionCapError: Requested message version, 4.17 is incompatible. It needs to be equal in major version and less than or equal in minor version as the specified version cap 4.11.

    [问题描述] RPCVersionCapError: Requested message version, 4.17 is incompatible. It needs to be equal in ...

  10. Vmware ESXI 安装Windows

    Vmware ESXI 安装Windows >ESXi专为运行虚拟机.最大限度降低配置要求和简化部署而设计.只需几分钟时间,客户便可完成从安装到运行虚拟机的全过程,特别是在下载并安装预配置虚拟设 ...