Codeforces Round #444 (Div. 2) A、B、C
来源:互联网 发布:vpn mac版本 编辑:程序博客网 时间:2024/06/04 19:43
题目链接
A:
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <vector>#include <map>#include <algorithm>using namespace std;const int maxn = 110;char str[maxn];int main(){ scanf("%s",str); int len = strlen(str); int i,j; int zero = 0, one = 0; for(i = len - 1; i>=0; i--){ if(str[i] == '0'){ ++zero; } if(zero >= 6 && str[i] == '1'){ ++one; } } if(one){ printf("yes\n"); }else{ printf("no\n"); } return 0;}
B:
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <vector>#include <map>#include <algorithm>using namespace std;int n;int num[5][20];bool vis[1010];int jyun[1010][10],tot;int now[10];void dfs(int index,int p, int sum){ vis[sum] = true; if(p>n){ //cout<<sum<<endl; return; } int i,j; for(i=1;i<=6;i++){ //cout<<"test "<<jyun[index][p]<<endl; dfs(index, p+1, sum + num[jyun[index][p]][i] * pow(10, p-1)); }}bool go[10];void killme(int p){ int i,j; if(p > n){ ++tot; for(i=1;i<=n;i++){ jyun[tot][i] = now[i]; } return; } for(i=1;i<=n;i++){ if(go[i]){ now[p] = i; go[i] = false; killme(p+1); go[i] = true; } }}void solve(){ tot = 0; killme(1); int i; for(i=1;i<=tot;i++){ dfs(i, 1, 0); }}int main(){ int i,j,a; while(~scanf("%d",&n)){ memset(vis, false, sizeof(false)); memset(go, true, sizeof(go)); for(i=1;i<=n;i++){ for(j=1;j<=6;j++){ scanf("%d",&num[i][j]); } } solve(); for(i=0;i<1000;i++){ if(!vis[i]){ printf("%d\n",i-1); break; } } } return 0;}
C:
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <vector>#include <map>#include <algorithm>using namespace std;int save[50];bool same(int a, int b, int c, int d){ if(save[a]==save[b]&&save[b]==save[c]&&save[c]==save[d]){ return true; }else{ return false; }}int main(){ int i; for(i=1;i<=24;i++){ scanf("%d",save+i); } bool flag = false; if(same(13,14,15,16) && same(17,18,19,20)){//right & left if(same(1,3,6,8) && same(5,7,10,12) && same(2,4,22,24) && same(9,11,21,23)){ flag = true; } if(same(6,8,9,11) && same(2,4,5,7) && same(10,12,22,24) && same(1,3,21,23)){ flag = true; } }else if(same(5,6,7,8) && same(21,22,23,24)){//front & back if(same(3,4,18,20) && same(11,12,17,19) && same(9,10,13,15) && same(1,2,14,16)){ flag = true; } if(same(3,4,13,15) && same(14,16,11,12) && same(9,10,18,20) && same(1,2,17,19)){ flag = true; } }else if(same(1,2,3,4) && same(9,10,11,12)){//up & down if(same(5,6,19,20) && same(17,18,23,24) && same(21,22,15,16) && same(13,14,7,8)){ flag = true; } if(same(5,6,15,16) && same(13,14,23,24) && same(21,22,19,20) && same(7,8,17,18)){ flag = true; } } if(flag){ printf("YES\n"); }else{ printf("NO\n"); } return 0;}
阅读全文
0 0
- Codeforces Round #444 (Div. 2) A、B、C
- Codeforces Beta Round #95 (Div. 2) A B C E
- 【CodeForce】Codeforces Round #140 (Div. 2) A B C
- 【CodeForce】Codeforces Round #142 (Div. 2) A B C
- Codeforces Round #160 (Div. 2)——A,B,C
- Codeforces Round #177 (Div. 2)——A,B,C
- Codeforces Round #179 (Div. 2)A、B、C、D
- Codeforces Round #184 (Div. 2)——A,B,C
- Codeforces Round #185 (Div. 2)——A,B,C
- Codeforces Round #186 (Div. 2)——A,B,C
- Codeforces Round #186 (Div. 2)A、B、C、D、E
- Codeforces Round #190 (Div. 2) A B C
- Codeforces Round #196 (Div. 2) A,B,C
- Codeforces Round #202 (Div. 2) (A、B、C、D)
- Codeforces Round #211 (Div. 2)(A,B,C,D)
- Codeforces Round #218,#217 (Div. 2) A.B.C
- Codeforces Round #220 (Div. 2)(A,B,C,D)
- Codeforces Round #228(Div.2) A,B,C,E
- 短信接口安全防护策略
- 遍历二叉树的神级方法(Morris遍历)
- Python3 在sublime text 的 console输出中文
- linux负载均衡总结
- ubuntu16.04安装vmware后集成显卡如何开启3D加速的问题解决思路
- Codeforces Round #444 (Div. 2) A、B、C
- QWidget背景设置
- Markdown在线编辑器
- Windows 系统安装Composer
- 大数据24小时:基因大数据公司安诺优达获7亿融资,腾讯发布AI助手“腾讯叮当”
- 数据猿专访农信互联魏春:如何在养猪场实现“普惠金融”?
- LINQ体验系列文章导航
- Linux用户管理
- java实现树形展示