ACM篇:POJ 1166--The Clocks
来源:互联网 发布:外汇手机交易软件 编辑:程序博客网 时间:2024/06/05 16:56
暴力。
#include <iostream>#include <cstdio>#include <vector>#include <cstring>using namespace std;const int CLOCKS = 9;const int move[CLOCKS][CLOCKS] = { {1, 1, 0, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 1, 1, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 1, 0, 0}, {0, 1, 0, 1, 1, 1, 0, 1, 0}, {0, 0, 1, 0, 0, 1, 0, 0, 1}, {0, 0, 0, 1, 1, 0, 1, 1, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0, 1, 1},};int clock[CLOCKS];int op[CLOCKS];vector<int> ans;void read_clock(){ for (int i = 0; i < CLOCKS; i++) scanf("%d", &clock[i]);}int is_ok(){ static int temp[CLOCKS]; for (int i = 0; i < CLOCKS; i++) temp[i] = clock[i]; for (int i = 0; i < CLOCKS; i++) { for (int j = 0; j < CLOCKS; j++) temp[j] += op[i] * move[i][j]; } for (int i = 0; i < CLOCKS; i++) if (temp[i] % 4) return 0; int cnt = 0; for (int i = 0; i < CLOCKS; i++) cnt += op[i]; return cnt;}void _dfs(int x){ int sz; if (sz = is_ok()) { if (sz < ans.size() || !ans.size()) { ans.clear(); for (int i = 0; i < CLOCKS; i++) { for (int j = 0; j < op[i]; j++) ans.push_back(i+1); } } return; } if (x >= 8) return; for (int i = 0; i < 4; i++) { op[x+1] = i; _dfs(x+1); }}void _print(){ for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);}int main(){ read_clock(); _dfs(-1); _print(); return 0;}
0 0
- ACM篇:POJ 1166--The Clocks
- POJ 1166 The clocks
- POJ 1166 The Clocks
- POJ 1166 The Clocks
- POJ 1166 The Clocks
- poj 1166 The Clocks
- POJ 1166 The Clocks
- poj 1166 The Clocks
- poj 1166 The Clocks
- poj 1166 The Clocks
- poj The Clocks 1166
- POJ 1166 The Clocks
- POJ 1166:The Clocks
- POJ 1166 The Clocks
- POJ The Clocks 1166
- POJ 1166 The Clocks 笔记
- Poj-1166-The Clocks-枚举
- POJ 1166 The Clocks(暴力搜索)
- daima
- 【艾米莉娅】Sicily:1001. Alphacode 代码分享
- AngularJS动画(二)
- Dialog 获取焦点的监听
- django models 模型
- ACM篇:POJ 1166--The Clocks
- Linux 隐藏文件及目录
- 添加自定义手势,UIGestureRecognizer
- controller返回jsp路径为转发,会出问题!!
- 高速公路ETC卡签之我见6-省级密钥系统建设
- zabbix 报警 超管可收 但 一般用户即使在administrator组里面依然不能收
- 缓存
- Eclipse下Ant自动打包,混淆和签名
- Unity3d_基础之GameObject.activeSelf,.activeInHierarchy,.SetActive的区别和关联