hdu 5292 Pocket Cube
来源:互联网 发布:游戏产业 知乎 编辑:程序博客网 时间:2024/05/01 15:19
题目链接:hdu 5292 Pocket Cube
本来想用暴力,从还原的魔方出发,遍历出所有的可能。但是看了下官方题解,挺牛逼的。考虑每个颜色对(黄,白),对于顺时为+1,逆时位-1,原位置0。总和为3的倍数就是可以还原的,否则就是不能还原。连接
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int bw[30] = {0, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 0, 0, 0, 0, 1, -1, -1, 1};int main () {int cas;scanf("%d", &cas);for (int kcas = 1; kcas <= cas; kcas++) {int ret = 0;char s[2];for (int i = 1; i <= 24; i++) {scanf("%s", s);if (s[0] == 'w' || s[0] == 'y')ret += bw[i];}printf("Case #%d: %s\n", kcas, ret % 3 ? "NO" : "YES");}return 0;}
0 0
- HDU 5292 Pocket Cube
- hdu 5292 Pocket Cube
- hdu 5292 Pocket Cube
- hdu 5292 Pocket Cube
- HDU 5292 Pocket Cube
- hdu 4801 Pocket Cube
- hdu 5983 Pocket Cube
- HDU 4801 Pocket Cube
- Pocket Cube HDU
- HDU 5983Pocket Cube
- HDU 4801 Pocket Cube BFS
- HDU 4801 Pocket Cube bfs
- [模拟]HDU 5983 Pocket Cube
- hdu 5983 Pocket Cube(模拟)
- 【HDU 5983 Pocket Cube】& 模拟
- HDU 5983 Pocket Cube 模拟
- HDU 5983 Pocket Cube (模拟)
- 2015 Multi-University Training Contest 1 Hdu 5292 Pocket Cube
- eclipse hadoop远程调试
- Formatting
- mac上的http请求监控软件
- PAT (Advanced Level) 1096. Consecutive Factors (20) 连续质因数
- 数字图像学习3
- hdu 5292 Pocket Cube
- presentmodalviewcontroller, dismissmodalviewcontroller详解
- 今年暑假不AC
- 黑马程序员-C语言const关键字的使用小结
- 方法的重写和重载
- 面试准备---Java异常
- 黑马程序员-C语言指针用法
- 单链表删除节点
- (最短路)dijkstra算法理解