poj 1006 暴搜
2015-11-02 21:07
351 查看
这道题要注意前三个数不是“第一次出现”,因此当前日期可能小于前三个数,所以要保证从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;
}
#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;
}
相关文章推荐
- 文件遍历排序函数
- Lua 学习笔记之C API 遍历 Table实现代码
- C#遍历文件夹后上传文件夹中所有文件错误案例分析
- C#中遍历Hashtable的4种方法
- Erlang中遍历取出某个位置的最大值代码
- C++实现图的邻接矩阵存储和广度、深度优先遍历实例分析
- C++实现图的邻接表存储和广度优先遍历实例分析
- C++非递归队列实现二叉树的广度优先遍历
- php遍历目录方法小结
- 一个目录遍历函数
- php遍历删除整个目录及文件的方法
- PHP遍历文件夹与文件类及处理类用法实例
- PHP遍历XML文档所有节点的方法
- php中使用key,value,current,next和prev函数遍历数组的方法
- C#使用前序遍历、中序遍历和后序遍历打印二叉树的方法
- C#使用foreach遍历哈希表(hashtable)的方法
- php递归遍历多维数组的方法
- C#使用yield关键字让自定义集合实现foreach遍历的方法
- C#使用foreach语句简单遍历数组的方法
- Javascript遍历Html Table示例(包括内容和属性值)