hdu4810Wall Painting dp+异或
来源:互联网 发布:西安java开发工资 编辑:程序博客网 时间:2024/06/06 12:28
//给出n个数,求出所有从c(n,k)中情况//从这n个数中选出k个的到的所有数异或值之和//dp[j][k][0] 前i个数,选j个数,用二进制表示第k位是0的数的个数//dp[j][k][1] 前i个数,选j个数,用二进制表示第k位是1的数的个数#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std ;const int maxn = 1e3+100 ;typedef unsigned long long ll ;const ll mod = 1e6+3 ;ll a[maxn] ;int dp[maxn][100][2] ;int main(){ int n ; while(~scanf("%d" , &n)) { memset(dp , 0 , sizeof(dp)) ; for(int i = 1;i <= n;i++) { scanf("%lld" , &a[i]) ; for(int j = i;j > 1;j--) { ll tmp = a[i] ; for(int k = 0;k < 64;k++) { ll tmp = ((ll)1<<k) ; if(tmp&a[i]) { dp[j][k][0] += dp[j-1][k][1] ; dp[j][k][1] += dp[j-1][k][0] ; } else { dp[j][k][0] += dp[j-1][k][0] ; dp[j][k][1] += dp[j-1][k][1] ; } if(dp[j][k][0] >= mod)dp[j][k][0] -= mod ; if(dp[j][k][1] >= mod)dp[j][k][1] -= mod ; } } for(int k = 0;k < 64;k++) { ll tmp = ((ll)1<<k) ; if(tmp&a[i]) dp[1][k][1]++ ; else dp[1][k][0]++ ; } } ll ans = 0 ; for(int i = 1;i <= n;i++) { ll ans = 0 ; for(int j = 0;j < 64;j++) { ll tmp = (ll)1<<j ; tmp = tmp%mod ; tmp = (tmp*dp[i][j][1])%mod ; ans = (ans + tmp)%mod ; } printf("%lld%c" , ans , i == n ?'\n':' ') ; } } return 0 ;}
0 0
- hdu4810Wall Painting dp+异或
- HDU 4810 Wall Painting 异或性质
- HDU 4810 Wall Painting(异或 +按位容斥)
- Codeforces Round #256 (Div. 2) C. Painting Fence 搜索或DP
- HDU 4810 Wall Painting (位操作-异或)
- HDU 4810 Wall Painting【二进制+异或+暴力枚举】
- HDU 4810 Wall Painting(异或数学)
- HDU 4810 Wall Painting(异或 组合数)
- zoj 3725 Painting Storages dp
- ZOJ 3725 Painting Storages DP
- ZOJ 3725 - Painting Storages(DP)
- Painting Storages(zju5048,DP+排列组合)
- ZOJ 3725 Painting Storages DP+排列计数
- Codeforces 398B Painting The Wall(dp)
- SGU 183 Painting the balls (DP优化)
- sgu183:Painting the balls(dp+优化)
- SGU183 Painting the balls(DP+优化)
- Painting A Board(状压dp)
- MATLAB图像处理工具箱
- 广义智能集论文
- python中pandas库学习笔记
- 关于BLL DAL MODEL的小问题
- android系统默认设置修改(1)-- 设置默认浏览器
- hdu4810Wall Painting dp+异或
- [动态规划]POJ3616(dp入门题)
- css 样式赶紧来look
- 利用python中的pyquery库简单的抓取数据
- Tree(MST模板题)
- 学习 MVC2=> Model与VIewModel 模型传值
- JavaScript对html获取节点的三种方法
- 张涛:12年老程序员在小米网干了什么
- iOS代理设计模式