poj1006
来源:互联网 发布:linux使用领域 编辑:程序博客网 时间:2024/05/02 02:29
计算周期,三个周期长度分别为23,28,33,3个分别有一个输入初始值a,b,c,所求数值加上初始值,求其最小公倍数,减去d即可。
即x+d-a%23=x+d-b%28=x+d-c%33=0同时满足。
#include<iostream>#include<math.h>using namespace std; #define PI 3.1415926int main(void){ int a,b,c,d; int t=0; while( cin>>a>>b>>c>>d){ t++; if(a== -1 &&b==-1 &&c==-1&&d==-1) return 0; int flag = 0; for(int i=1;;i++){ if((i+d-a)%23 == 0 and (i+d-b)%28 == 0&&(i+d-c)%33 == 0){ flag = 1; cout<<"Case "<<t<<": the next triple peak occurs in "<<i<<" days."<<endl; } if(flag==1) break; } } //system("pause"); return 0; }
0 0
- POJ1006
- POJ1006
- poj1006
- poj1006
- poj1006
- POJ1006
- poj1006
- poj1006
- poj1006
- POJ1006
- POJ1006
- POJ1006
- POJ1006
- poj1006
- poj1006
- POJ1006
- poj1006
- Poj1006
- 在ubuntu上配置xunsearch全文搜索引擎
- VS制作程序安装包
- 在android应用中使用luasocket
- Spark SQL 源码分析系列文章
- tar -zxvf 和不带-
- poj1006
- gethostbyname() -- 用域名或主机名获取IP地址
- Google Android官方培训课程中文版
- ESL-chapter10-boosting
- 正则表达式30分钟入门教程
- uva 1599 - Ideal Path
- 设计模式之单例模式
- HDU1757矩阵的简单运用
- 复制原文件取消原有svn痕迹