POJ 1006.Biorhythms

水题,注意在一开始日期的遍历要从给的第四个输入开始,一开始因为这个WA了不少次

题目链接

代码:

#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <cmath>
#include <cstdlib>
//23 28 33
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char** argv) {
	
	int jishu = 1;
	
	
	while(1)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a==-1&&b==-1&&c==-1&&d==-1)
		return 0;
//	int count = 0;
//	int minnumber = a;
//	if(b<minnumber)
//	{
//		minnumber= b;
//	}
//	if(c<minnumber)
//	{
//		minnumber = c;
//	}
	for(int i=d+1;;i++)//这里的i为什么要从d开始 因为至少在这一天后边 
	{
		if((i-a)%23==0&&(i-b)%28==0&&(i-c)%33==0)
		{
		if((i-d)!=21252) 
			printf("Case %d: the next triple peak occurs in %d days.\n",jishu,(i-d)%21252);
		else
			printf("Case %d: the next triple peak occurs in %d days.\n",jishu,21252);
			jishu++;
			break;
		}
	}
}
	//i最终的输出值是一个天数,所以这个i的值肯定要大于d 
	//system("pause");
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值