题目链接
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){
return;
}
int i,j;
for(i=1;i<=6;i++){
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)){
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)){
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)){
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;
}