枚举 PROBLEM 1 生理周期

/**give one day that 3 physiological peak occur simultaneously */

代码
#include <cstdlib>
#include
<iostream>

using namespace std;
/**
*this program is a daily test
*problem set 1 : enumeration
* problem 1 : physiological cycle
*/
int main(int argc, char *argv[])
{
int p=0;
int e=0;
int i=0;
int d=0;
int k=0;
while(1)
{
printf(
"INPUT \n");
scanf(
"%d%d%d%d",&p,&e,&i,&d);
//you should simultaneously satisfy 3 conditions
for(k=d+1;k<21252;k++)
{
if(0==(k-p)%23)
{
break;
}
}
for(;k<21252;k=k+23) //notice k+23..not k+1
{
if(0==(k-e)%28)
{
break;
}
}
for(;k<21252;k=k+23*28)
{
if(0==(k-i)%33)
{
break;
}
}
printf(
"the next physiological cycle is %d \n",k-d);
}
system(
"PAUSE");
return EXIT_SUCCESS;
}

 

总结:

重新开始做acm题,发现编程已经相当生疏。

解决了dev-c++ 不能debug的问题

posted @ 2010-04-15 11:24  love && peace  阅读(213)  评论(0编辑  收藏  举报