poj 1006 暴搜

這道題要注意前三個數不是“第一次出現”,因此當前日期可能小於前三個數,所以要保證從current year 的第一個 peak 遍歷起

#include<iostream>  
#include<map>
#include<string>   
#include<algorithm>  
#include<fstream>
#include<cmath>  
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;  
#define lch(i) ((i)<<1)  
#define rch(i) ((i)<<1|1)  
#define sqr(i) ((i)*(i))  
#define pii pair<int,int>  
#define mp make_pair  
#define FOR(i,b,e) for(int i=b;i<=e;i++)  
#define FORE(i,b,e) for(int i=b;i>=e;i--)  
#define ms(a)   memset(a,0,sizeof(a))  
const int maxnum =21252;
const  int  mod = 10007;
int n,m;



//
//#define _DEBUG_ 1;

int main()    
{  
#ifdef _DEBUG_
	fstream fin("G:/1.txt");
#else
#define fin cin
#endif
	int a,b,c,now,t=0;
	for(;;){
		fin>>a>>b>>c>>now;
		if(a==-1&&b==-1&&c==-1&&now==-1) break;
		
		int sum ;
		for(int i=-15;i<=645;i++){
			sum = c+33*i;
			if(sum>now&&(sum-a)%23==0&&(sum-b)%28==0){
				printf("Case %d: the next triple peak occurs in %d days.\n",++t,sum-now);
				break;
			}

		}
		

	}
	return 0;
}  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章