Problem 1006 Biorhythms

SourceCode(C)

#include <stdio.h>
 
int main(void)
{
 	int cNum=0;
	int max = 1;
	while(++cNum){
		int p,e,i,d;
		scanf("%d%d%d%d",&p,&e,&i,&d); 
		if(p+e+i+d==-4) break;
		p %= 23;
		e %= 28;
		i %= 33;
		for(max = 1;max<=21252;max++){
			if(max%23 == p && max%28 == e && max%33 == i) break;
		}
		d = (max+21251-d)%21252 +1
		printf("Case %d: the next triple peak occurs in %d days.\n",cNum,d);
	}
	return 0;
}
最終更新:2006年09月11日 11:24