题目1142:Biorhythms

来源:互联网 发布:上古卷轴5ece捏脸数据 编辑:程序博客网 时间:2024/05/16 15:47
#include<stdio.h>#include<string.h>#include<stdlib.h> int cal(int a,int b,int c,int d){    int sum=21252;    int a_23=23,b_28=28,c_33=33;    int a_day=0,b_day=0,c_day=0;    while(a>a_23)        a_23+=23;    a_day=a_23-a;    while(b>b_28)        b_28+=28;    b_day=b_28-b;    while(c>c_33)        c_33+=33;    c_day=c_33-c;    int x;    for(x=0;x<=21252;x++)    {        if((a_day+x)%23==0&&(b_day+x)%28==0&&(c_day+x)%33==0)            break;    }    sum=x-d;    if(sum<=0)        sum+=21252;         return sum;} int main(){    int a,b,c,d;    int cas=1;    while(scanf("%d %d %d %d",&a,&b,&c,&d))    {        if(a==-1&&b==-1&&c==-1&&d==-1)            break;        printf("Case %d: the next triple peak occurs in %d days.\n",cas++,cal(a, b, c, d));    }    return 0;}/**************************************************************    Problem: 1142    User: cust123    Language: C++    Result: Accepted    Time:10 ms    Memory:1020 kb****************************************************************/

0 0
原创粉丝点击