| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
屈指一数,不是只有八种情况吗?为什么WA呢,请指教...#include <stdio.h>
#include <string.h> //每次变换灯的变化都是独立于其他灯,相互之间没有干扰
char str[8][101]={ //一百盏灯用题目的四种条件变换,只能取下面八种情况,不知道是不是只有这八种情况? //1 2 3 4
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",//1 0 0 0 奇
"0011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011",//0 0 1 1 偶
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",//0 1 0 0 奇
"0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110",//0 0 0 1 奇
"1001001001100100100110010010011001001001100100100110010010011001001001100100100110010010011001001001",//1 0 0 1 偶
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",//0 0 1 0 奇
"1100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100",//0 1 0 1 偶
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",//0 0 0 0 偶
};
int oo[8]={1,0,1,1,0,1,0,0}; //字符串的奇偶次数
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int i,j,N,C,on,off,opt[8];
while(scanf("%d",&N)!=EOF){
scanf("%d",&C);
C=C%2;
for(i=0;i<8;i++) opt[i]=1; //假设全部符合条件
while(1){
scanf("%d",&on);
if(on==-1) break;
for(j=0;j<8;j++)
if(str[j][on-1]=='0') opt[j]=0; //不符合灯 "打开" 的条件
}
while(1){
scanf("%d",&off);
if(off==-1) break;
for(j=0;j<8;j++)
if(str[j][off-1]=='1') opt[j]=0; //不符合灯 "关闭" 的条件
}
for(i=0;i<8;i++){
if(opt[i]==1 && C==oo[i]){ //去掉不符合奇偶条件
for(j=0;j<N;j++) printf("%c",str[i][j]);
printf("\n");
}
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator