Codeforces 383E Vowels (容斥+莫比乌斯变换)
2016-03-22 22:38
477 查看
By doubility, contest: Codeforces Round #225 (Div. 1), problem: (E) Vowels, Accepted, # #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <map> #include <vector> using namespace std; const int N = 1 << 24; #define M 400030 #define mod 1000000007 #define B 234324 #define LL long long int f[1<<24]; int n, a ; char str[5]; int c[1<<24]; int main() { for(int i = 1; i < (1 << 24); ++i) c[i] = c[i-(i&-i)] + 1; scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%s", str); for(int j = 1; j < (1 << 3); ++j) { int cnt = 0; int s = 0; for(int k = 0; k < 3; ++k) { if(j >> k & 1) { ++cnt; s |= 1 << (str[k] - 'a'); } } if(cnt & 1 ^ 1) f[s]--; else f[s]++; } } for(int j = 0; j < 24; ++j) { int t = N - 1 - (1 << j); int v = 1 << j; for(int s = t; s; s = (s - 1) & t) { f[s|v] += f[s]; } f[1<<j] += f[0]; } int ans = 0; for(int s = 0; s < (1 << 24); ++s) { int tmp = f[s]; ans ^= tmp * tmp; } printf("%d\n", ans); return 0; }
相关文章推荐
- 面向科研的编程技巧
- 3.16Java基础总结 IO全部
- 2016网易春招Java在线笔试回忆录
- OC中的load和initialize方法
- android面试题整理
- ExtJs之Ext.core.DomHelper.append
- Adaboost的意义
- 机电传动控制第四周作业
- dataRow转化为对象
- Django--models基础
- 内部类
- static final(关键字)
- LINUX下的简单方便的电子相册制作工具VideoParama,可替代会声会汇制作简单的电子相册
- 简析struct in_addr ,struct sockadd
- 多播 、IP_ADD_MEMBERSHIP 、IP_MULTICAST_IF
- 项目4-求fibnacci数第n项
- Java day08 异常实例 上课时电脑出问题
- (一)JavaScript之[数据类型]与[对象]
- 简单SQL的增、删、改、查语句
- Tensorflow安装记录