zoukankan      html  css  js  c++  java
  • WUST Online Judge

    2103: 生理周期

    Time Limit: 1 Sec  Memory Limit: 128 MB   64bit IO Format: %lld
    Submitted: 315  Accepted: 99
    [Submit][Status][Web Board]

    Description

    人有体力、情商、智商的高峰日子,它们分别每隔23 天、28 天和 33 天出现一次。 

    对于每个人,我们想知道何时三个高峰落在同一天。 

    给定三个高峰出现的日子p,e和i(不一定是第一次高峰出现的日子),再给定另一个指定的日子d,你的任务是输出日子d之后,下一次三个高峰落在同一天的日子(用距离d的天数表示 )。

    例如:给定日子为10,下次出现三个高峰同一天的日子是12,则输出2。

    Input

    多组测试数据,每组测试数据在一行中输入四个整数:p,e,i和d。p,e,i分别表示体力、情感和智商高峰出现的日子。d是给定的日子,可能小于p,e 或i。所有给定日子是非负的并且小于或等365,所求的日子小于或等于21252。

    Output

    每组测试数据的输出占一行(具体格式Sample Output )。

    Case #n: the next triple peak occurs in s days.

    其中n为传输数据组数,从1开始计数。s表示从给定日子起下一次三个高峰同一天的日子(距离给定日子的天数)。

    Sample Input

    0 0 0 0
    0 0 0 100
    5 20 34 325
    4 5 6 7
    283 102 23 320
    203 301 203 40
    

    Sample Output

    Case #1: the next triple peak occurs in 21252 days.
    Case #2: the next triple peak occurs in 21152 days.
    Case #3: the next triple peak occurs in 19575 days.
    Case #4: the next triple peak occurs in 16994 days.
    Case #5: the next triple peak occurs in 8910 days.
    Case #6: the next triple peak occurs in 10789 days.
    

    代码如下:

    #include <stdio.h>
    
    int main() {
        int i, P, E, I, D, flag = 0;
        while (scanf("%d%d%d%d", &P, &E, &I, &D) != EOF) {
            flag++;
            P %= 23; E %= 28; I %= 33;
            for (i = I; ; i += 33) {
                if ((i - E) % 28 == 0 && (i - P) % 23 == 0 && (i - I) % 33 == 0 && i > D)
                    break;
            }
            printf("Case #%d: the next triple peak occurs in %d days.
    ", flag, i - D);
        }
        return 0;
    }
    
    作者:McR
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Swift3.0P1 语法指南——闭包
    OS X EI Capitan安装refind时出现Could not set boot device property: 0xe00002bc
    Swift3.0P1 语法指南——函数
    Swift3.0P1 语法指南——控制流
    [转]ios push
    给新浪微博审核提供下载地址
    xcode gdb/lldb调试命令
    博弈的真谛到底是什么?
    图基本算法 拓扑排序(基于dfs)
    HDU 1325 Is It A Tree? 判断是否为一棵树
  • 原文地址:https://www.cnblogs.com/mcr-tcp/p/9170575.html
Copyright © 2011-2022 走看看