33属地(2)79(3)117(4)
来源:互联网 发布:网络性能指标 编辑:程序博客网 时间:2024/05/05 22:18
智力游戏
规则和1属地(1)差不多,但是从3*3变成了3*4
1 2 5 0
1 2 3 4 0
1 2 3 4 0
3 4 8 0
1 5 9 0
2 5 6 7 10 0
3 6 7 8 11 0
4 8 12 0
5 9 10 0
9 10 11 12 0
9 10 11 12 0
8 11 12 0
1 2 3 4 0
1 2 3 4 0
3 4 8 0
1 5 9 0
2 5 6 7 10 0
3 6 7 8 11 0
4 8 12 0
5 9 10 0
9 10 11 12 0
9 10 11 12 0
8 11 12 0
根据这个规则,要过关很容易,但是要总结成固定的攻略就比较繁琐了。
所以我干脆编程解决。
这么做的很重要的一个原因是,每个格子只有3种状态,所以全局也只有3^12=531441种状态,所以可以用枚举法求出答案。
代码:
#include<iostream>using namespace std;int main(){int list[12][12];for (int i = 0; i < 12; i++)for (int j = 0; j < 12; j++)list[i][j] = 0;cout << "输入每个格子影响哪些格子,用0表示输入完毕" << endl;for (int i = 0; i < 12; i++){int a;for (int j = 0; j < 12; j++){cin >> a;if (a>0)list[a - 1][i] = 1;else break;}}int color[12];cout << "输入每个格子需要变化几次才能复原" << endl;for (int i = 0; i < 12; i++)cin >> color[i];
for (int x1 = 0; x1 < 3; x1++)for (int x2 = 0; x2 < 3; x2++)for (int x3 = 0; x3 < 3; x3++)for (int x4 = 0; x4 < 3; x4++)for (int x5 = 0; x5 < 3; x5++)for (int x6 = 0; x6 < 3; x6++)for (int x7 = 0; x7 < 3; x7++)for (int x8 = 0; x8 < 3; x8++)for (int x9 = 0; x9 < 3; x9++)for (int xa = 0; xa < 3; xa++)for (int xb = 0; xb < 3; xb++)for (int xc = 0; xc < 3; xc++)
{bool flag = true;for (int i = 0; i < 12; i++){int s = list[i][0] * x1 + list[i][1] * x2 + list[i][2] * x3 + list[i][3] * x4 + list[i][4] * x5 + list[i][5] * x6 + list[i][6] * x7 + list[i][7] * x8 + list[i][8] * x9 + list[i][9] * xa + list[i][10] * xb + list[i][11] * xc;if ((s - color[i]) % 3 != 0){flag = false;break;}}if (flag){cout << "下面是每个格子需要点击的次数" << endl;cout << x1 << x2 << x3 << x4 << endl;cout << x5 << x6 << x7 << x8 << endl;cout << x9 << xa << xb << xc;cout << endl << endl << "end";system("pause>nul");return 0;}}}
示例:
79(3)
规则和上面的33属地(2)不一样,具体如下:
影响矩阵是:
1 6 11 0
2 7 12 0
3 6 9 0
4 7 10 0
1 5 9 0
2 5 6 7 10 0
3 6 7 8 11 0
4 8 12 0
3 6 9 0
4 7 10 0
1 6 11 0
2 7 12 0
蓝色是0,绿色是1,红色是2
运行上面的程序即可得到答案117(4)
影响矩阵是:
1 5 9 10 0
2 6 9 10 0
3 7 11 12 0
4 8 11 12 0
3 5 6 7 0
4 6 7 8 0
1 5 6 7 0
2 3 4 8 0
7 9 10 11 0
2 3 6 10 0
3 4 7 11 0
6 7 8 12 0
淡黄色是0,绿色是1,红色是2
运行上面的程序即可得到答案 1 0
- 33属地(2)79(3)117(4)
- 1属地(1)
- 根据属地id选择子属地
- IP地址属地查询测试用例,涵盖31个省会和3个运营商
- 品牌属地一览
- HttpClient 获得手机规属地
- 中国移动咪咕属地化2016校招面经
- 根据属地选择地州联动菜单
- java : apache cxf client 查询手机号码属地
- 【java】利用第三方的IP地址属地查询
- PHP获取手机号归属地,PHP获取2017最新手机号段属地类
- 117-epoll(基础)
- 挑战程序竞赛系列(79):4.3 2-SAT(3)
- leetCode练习(79)
- Codeforces Round #117 (Div. 2)E---Wooden Fence(dp)
- 第314(33W+4)
- (117)BitMask蓝图变量
- Qt 学习之路 2(33):贪吃蛇游戏(3)
- TFT-LCD驱动程序设计(系列二)
- Linux 软中断机制分析
- 简单的登陆注册练习1 登陆
- mysql5.7+安装教程
- 最近的一些收获
- 33属地(2)79(3)117(4)
- 作用域和Servlet监听器
- Problem 34 Digit factorials (暴力)
- mysqldump命令
- Thymeleaf的使用
- writev碰上非阻塞IO--纯扯淡
- The type org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved.
- AJAX下跨域的实现
- 编译过程、动静态库