HDU4810_Wall Painting
题目很简单。
给你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的更多相关文章
- CF448C Painting Fence (分治递归)
Codeforces Round #256 (Div. 2) C C. Painting Fence time limit per test 1 second memory limit per tes ...
- [译]使用Continuous painting mode来分析页面的绘制状态
Chrome Canary(Chrome “金丝雀版本”)目前已经支持Continuous painting mode,用于分析页面性能.这篇文章将会介绍怎么才能页面在绘制过程中找到问题和怎么利用这个 ...
- Codeforces Round #353 (Div. 2)Restoring Painting
Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was sto ...
- hdu-4810 Wall Painting(组合数学)
题目链接: Wall Painting Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Codeforces Gym 100342C Problem C. Painting Cottages 转化题意
Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- F面经:painting house
There are a row of houses, each house can be painted with three colors red, blue and green. The cost ...
- 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 4810 Wall Painting
Wall Painting Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- UVA 253 Cube painting(暴力打表)
Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...
随机推荐
- day1 post验证登录
用post方式模拟 1.登录抽屉网 2.登录代码 ,URL,Form Data 中的信息写入 # coding=utf-8 #post 登录验证 import requests form_data = ...
- CF 1025 D. Recovering BST
D. Recovering BST http://codeforces.com/contest/1025/problem/D 题意: 给出一个连续上升的序列a,两个点之间有边满足gcd(ai ,aj) ...
- 10_SpringBoot集成TkMybatis插件
10_SpringBoot集成TkMybatis插件 明天你好向前奔跑 关注 0.5 2018.09.11 11:15 字数 163 阅读 3794评论 0喜欢 3 @Author Jacky Wa ...
- 提取验证码到winform上webbroswer和axwebbroswer
在网上只有webbroswer的代码,所以自己又修改了修改改成axwebbroswer的 public static class yanZhengMaHelp { //webbrowser验证码 pu ...
- Vue.js之常用指令
vue常用指令 vue.js官方给自己的定义是数据模板引擎,并给出了一套渲染数据的指令.本文详细介绍vue.js的常用指令. 官网:点我 一.v-text.v-html v-text:用于绑定文本 v ...
- 二、Django快速安装
一.安装Python 作为一个Python Web框架,Django依赖Python.从Django适用于哪些版本的Python可以获取更多信息.较新版本的Python内置一个轻量级的数据库SQLit ...
- 个人安装ss的一个记录
在ubuntu16.04安装ss服务.由于lantern最近极其不稳定(我还花钱的qaq),经常断联以至于几乎废了,莫得办法,只好花钱搭一个了orz...呵,贫穷.... 安装shadowsocks ...
- Python基础灬异常
异常&异常处理 异常!=错误 在程序运行过程中,总会遇到各种各样的错误. 有的错误是程序编写有问题造成的,比如本来应该输出整数结果输出了字符串,这种错误我们通常称之为bug,bug是必须修复的 ...
- arcgis10.2怎么把地理坐标系转化为投影坐标系(平面,米制坐标) arcmap 10.2 从 WGS_1984 转 Beijing_1954
方法一:在Arcmap中转换:从 WGS_1984 转 Beijing_19541.加载要转换的数据,右下角为经纬度2.点击视图——数据框属性——坐标系统3.导入或选择正确的坐标系(如选:Beijin ...
- rest_framework之渲染器
渲染器简介 什么是渲染器 根据 用户请求URL 或 用户可接受的类型,筛选出合适的 渲染组件. 渲染器的作用 序列化.友好的展示数据 渲染器配置 首先要在settins.py中将rest_framew ...