b095: A. 測謊機

http://zerojudge.tw/ShowProblem?problemid=b095

// scanf("%d.%d",&a,&b)

#include<iostream>

using namespace std;

int main() {

int a,b,c,max,count,found;

for(int i=0;i<10;i++){

count=0;

found=0;

cin >> a>>b;

if (a>b) {

max=a;

}else{

max=b;

}

for(int j=0;j<30;j++){

cin >>c;

if ((c!=0)&&(c!=max)) {

count++;

}

if (c==max){

found=1;

if (count < 3) {

cout<<"Y"<<endl;

}

if (count >= 3) {

cout<<"N"<<endl;

}

for(int k=j+1;k<30;k++){

cin >> c;

}

break;

}

if ((j==29)&&(found==0)){

cout << "N" <<endl;

}

}

}

}