/*
开始,时间0秒,每人都拍了一次,
teacher 1秒 1次
nike 2秒1次
glair 4秒1次
试编写一程序,算一算观众可听到多少声掌声。
每人都拍10次
*/
#include<iostream>
using namespace std;
int main()
{
//time
//count:观众听到的拍手的次数
//teacher,nike, glair 拍手的次数
int time, count,teacher,nike, glair;
bool flag;
time=0;
count=1;
teacher=nike=glair=0;
do
{
flag=0;
time++;
//0 1 2 3 4 5 6 7 8 9
if(teacher<9)
{
flag=1;
teacher++;
}
//0 2 4......
if(nike<9&& time%2==0)
{
flag=1;
nike++;
}
//0,4,8.....
if( glair<9 && time%4==0)
{
flag=1;
glair++;
}
if(flag) count++;
}while(teacher+nike+glair<9*3);
cout<<count<<endl;
cout<<"time="<<time<<endl;
return 0;
}