UVA 1326 B
来源:互联网 发布:淘宝富光保温杯 编辑:程序博客网 时间:2024/06/01 07:41
不用位运算会超时
#include <cstdio>using namespace std;int main() { char str[30]; int n, a[30], cnt, ans; while (~scanf("%d", &n)) { for (int i = 0; i < n; i++) { scanf("%s", str); a[i] = 0; for (int j = 0; str[j]; j++) a[i] ^= (1<<(str[j] - 'A')); } cnt = ans = 0; for (int i = 1; i < (1<<n); i++) { int t = 0, c = 0; for (int j = 0; j < n; j++) if (i & (1<<j)) t ^= a[j], c++; if (t == 0 && c > cnt) { cnt = c, ans = i; } } int flag = 0; printf("%d\n", cnt); for (int i = 0; i < n; i++) { if (ans & (1<<i)) { if (flag++) printf(" "); printf("%d", i + 1); } } printf("\n"); }}
阅读全文
0 0
- UVA 1326 B
- Uva 6173 B-Casting
- Uva-10891(dp专组B)
- (Uva)Buy or Build(B)
- 699UVa"\b"的问题
- B(UVA-11997)k个最小和
- UVA 465 (暑假-高精度 -B - Overflow)
- uva 12721 Cheap B-Subsequence 背包
- UVA - 11526(a/b式子计算)
- UVA - 10921 - Problem B - Find the Telephone
- B - The Blocks Problem UVA - 101
- uva 1326
- From:UVA, 10026 Problem B : Shoemaker's Problem
- uva 10404 Problem B: Bachet's Game 迭代
- UVA 409 (暑假-字符串(2) -B - Excuses, Excuses!)
- UVA 10420 (暑假-排序、检索 -B - List of Conquests)
- UVA 10161 (暑假-数学-B - Ant on a Chessboard)
- UVA 375 (暑假-几何 -B - Inscribed Circles and Isosceles Triangles)
- EventBus使用详解(二)——EventBus使用进阶
- servlet应用过滤器
- ArrayList循环遍历并删除元素的常见陷阱
- Struts2+Android 多种方式向服务器发送信息
- React-Router入门
- UVA 1326 B
- 数组与方法
- NOIP2017提高组 模拟赛24(总结)
- 喷水装置(二)
- 理解原型链
- coinhive是什么?
- [agc019e]Shuffle and Swap
- 关于同一服务器配置多个tomcat的问题
- Servlet (三 Response 对象)