Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:过了,的确只有八种情况,只是次数 C 跟各种情况有一定冲突

Posted by yuanyirui at 2007-03-04 19:22:54 on Problem 1176
In Reply To:屈指一数,不是只有八种情况吗?为什么WA呢,请指教... Posted by:yuanyirui at 2007-03-04 18:30:26
#include <stdio.h>
#include <string.h>
char str[8][101]={ //一百盏灯用题目的四种条件变换,只能取下面八种情况,不知道是不是只有这八种情况?      //1 2 3 4 
  "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",//1 0 0 0 all 
  "0011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011",//0 0 1 1 !=1
  "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",//0 1 0 0 all
  "0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110",//0 0 0 1 !=2
  "1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001",//1 0 0 1 !=1
  "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",//0 0 1 0 all
  "1100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100",//0 1 0 1 !=1
  "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",//0 0 0 0 !=1
  };
int oo[8]={0,1,0,2,1,0,1,1}; //字符串次数的要求 
int main()
{
  //  freopen("min5.txt","r",stdin);
  //  freopen("mout5.txt","w",stdout);
    int i,j,N,C,on,off,opt[8];
    while(scanf("%d",&N)!=EOF){
        scanf("%d",&C);
        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] || (C==1&&i==3))){      //去掉不符合次数的条件 
                for(j=0;j<N;j++) printf("%c",str[i][j]);
                printf("\n");
            }
        }
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator