Gym 101158B Quality of Check Digits
来源:互联网 发布:网络犯罪的客观原因有 编辑:程序博客网 时间:2024/05/17 23:53
这个题的题目要求就是找一个abcd。然后找出e 再去判断abcde是否是零。可以替换,这个题让找,不是零的都多少个,这样就是直接暴力,枚举1到1万,然后暴力5个循环,如果当前数位的数不等于j 就检查一遍,然后,最后的时候注意,每一个数位不能相等,然后你变换一下位置,再检查一遍就可以了。
#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;const int maxn=600000+200;int m[15][15];int x1,x2,x3,x4,x5,ans;bool judge(int a,int b,int c,int d,int e){ int xx = 0; xx = m[0][a]; xx = m[xx][b]; xx = m[xx][c]; xx = m[xx][d]; xx = m[xx][e]; return xx;}int main(){ for(int i = 0; i <= 9; i++) for(int j = 0; j <= 9; j++) { cin>>m[i][j]; } ans = 0; for(int i = 0; i <= 9999; i++) { x1 = i / 1000; x2 = i / 100 % 10; x3 = i / 10 % 10; x4 = i % 10; x5 = m[0][x1]; x5 = m[x5][x2]; x5 = m[x5][x3]; x5 = m[x5][x4]; int flag = 1; //cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl; for(int j = 0; j <= 9; j++) { if(x1 != j) { if(!judge(j,x2,x3,x4,x5)) { flag = 0; } } } for(int j = 0; j <= 9; j++) { if(x2 != j) { if(!judge(x1,j,x3,x4,x5)) { flag = 0; } } } for(int j = 0; j <= 9; j++) { if(x3 != j) { if(!judge(x1,x2,j,x4,x5)) { flag = 0; } } } for(int j = 0 ; j <= 9; j++) { if(x4 != j) { if(!judge(x1,x2,x3,j,x5)) { flag = 0; } } } for(int j = 0; j <= 9; j++) { if(x5 != j) { if(!judge(x1,x2,x3,x4,j)) { flag = 0; } } } if(x1 != x2 && !judge(x2,x1,x3,x4,x5)) flag = 0; if(x2 != x3 && !judge(x1,x3,x2,x4,x5)) flag = 0; if(x3 != x4 && !judge(x1,x2,x4,x3,x5)) flag = 0; if(x4 != x5 && !judge(x1,x2,x3,x5,x4)) flag = 0; if(!flag) ans++; } printf("%d\n",ans);}
阅读全文
1 0
- Gym 101158B Quality of Check Digits
- Codeforces Gym 101158 B. Quality of Check Digits (模拟)
- B Quality of Check Digits
- ACM Asia Regional Contest B题 Quality of Check Digits
- Aizu 1368 Quality of Check Digits 模拟|签到
- B. Sum of Digits
- B. Maximize Sum of Digits
- Check Sheet as a Component of Seven Basic Quality Tool
- codeforces 770B Maximize Sum of Digits
- CF770-B-Maximize Sum of Digits
- A Lot of Joy-Gym 100187B
- Gym 100187B - A Lot of Joy
- 【Codeforces Gym】 100162B Circle of Stones
- Multiplying Digits Gym
- codeforces Gym 100187 B. A Lot of Joy (期望)
- Gym 100818B Tree of Almost Clean Money
- [Codeforces Gym] 100162B Circle of Stones 结论+Hash
- Codeforces Gym 100187 B A Lot of Joy(期望)
- cocos2d中去掉微信呢称中的表情字符(ios与android)
- 颓废了?看看这些!
- 天天学Linux命令11--cat命令
- (二)java从零开始
- Eclipse警告解决:Implementation of project facet maven could not be found. Functionality will be limited
- Gym 101158B Quality of Check Digits
- ext新建主题失败
- 基于Android的“健康宝”体检APP(三)
- 日志转换成json格式
- 软考--J2SE视频总结
- AOP相关术语
- postgresql常用命令
- Kotlin语法特征及特性
- 区块链是什么,如何简单易懂地介绍区块链?