1006:Biorhythms
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
(77条消息) 百炼1006--Biorhythms_百练 1006_zha_zha_wei的博客-CSDN博客
中等难度 回练
#include <stdio.h>
#include <string.h>
#define M 40000
bool ans[3][M];
int main()
{
int p, e, i, d;
int n(0);//计录循环数的
while(scanf("%d%d%d%d", &p, &e, &i, &d) != EOF && p >= 0)
{
memset(ans, 0, sizeof(ans));
p = p % 23;//得到在一个周期内高峰第几天
e = e % 28;
i = i % 33;
for(int x = p; x < M; x += 23)//把各自的高峰天打张表
ans[0][x]++;
for(int x = e; x < M; x += 28)
ans[1][x]++;
for(int x = i; x < M; x += 33)
ans[2][x]++;
for(int x = d + 1; x < M; x++)
if(ans[0][x] == 1 && ans[1][x] == 1 && ans[2][x] == 1 )
{
printf("Case %d: the next triple peak occurs in %d days.\n", ++n, x - d);
break;
}
}
return 0;
}