zoukankan      html  css  js  c++  java
  • SGU[276] Andrew's Troubles

    Description

    描述

    Famous Berland ACM-ICPC team Anisovka consists of three programmers: Andrew, Michael and Ilya. A long time ago, during the first few months the team was founded, Andrew was very often late to the trainings and contests. To stimulate Andrew to be more punctual, Ilya and Andrew decided to introduce a new rule for team participants. If somebody is late (i.e. comes at least one second after appointed time) he owes a cup of tea to other team members. If he is late for 5 minutes, he owes two cups of tea. If he is late for 15 minutes, he owes three cups of tea. And if he is late for 30 minutes or more, he owes 4 cups of tea. 

    著名的Berland ACM-ICPC队Anisovka由3个队员组成:Andrew、Michael、Ilya。很久以前,在这个队刚刚成立的前几个月内,Andrew在训练或者比赛时总是迟到。为了使得Andrew更加守时,Ilya和Andrew决定采用一套新的队伍管理方案。如果某人迟到(预定时间后至少一秒),他需要给队员们一杯茶,如果迟到5分钟,需要2杯,如果迟到15分钟,需要3杯,如果迟到30分钟或者更多,需要4杯。

    The training starts at the time S (counted in seconds, from some predefined moment of time) and Andrew comes at the time P (also in seconds, counted from the same moment of time). 
    Your task is to find how many cups of tea Andrew owes.

    训练从S(以秒计时,从某个预定的时刻开始)时刻开始,Andrew在P(以秒计时,从一样的预定时间开始)时刻到达。

    你的任务是Andrew需要买多少杯茶。

     

    Input

    输入

    The input file contains single line with integer numbers S and P (0 <= S,P <= 10^4). 

    输入文件包含一行两个整数S和P(0 <= S, P <= 10^4)。


    Output

    输出

    Write to the output file the number of cups Andrew owes. 

    输出Andrew需要买的茶的杯数。


    Sample Input #1

    样例输入 #1

    10 10


    Sample Output #1

    样例输出 #1

    0

     

    Sample Input #2

    样例输入 #2

    10 11


    Sample Output #2

    样例输出 #2

    1

     

    Sample Input #3

    样例输入 #3

    0 300


    Sample Output #3

    样例输出 #3

    2

     

    Analysis

    分析

    水题。

     

    Solution

    解决方案

    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int S, P;
    	while(cin >> S >> P)
    	{
    		int nDiff = P - S;
    		if(nDiff <= 0) { cout << 0 << endl; }
    		else if(nDiff >= 1 && nDiff < 300) { cout << 1 << endl; }
    		else if(nDiff >= 300 && nDiff < 900) { cout << 2 << endl; }
    		else if(nDiff >= 900 && nDiff < 1800) { cout << 3 << endl; }
    		else { cout << 4 << endl; }
    	}
    	return 0;
    }
    

      

    练练手。

  • 相关阅读:
    (转)【经验之谈】Git使用之Windows环境下配置
    (转)SQL Server内存遭遇操作系统进程压榨案例
    (转)【javascript基础】原型与原型链
    (转)微信公众平台开发教程目录
    (转)C# .net微信开发,开发认证,关注触发消息,自动应答,事件响应,自定义菜单
    (转)利用快速开发框架,快速搭建微信浏览博客园首页文章
    (转)微信公众平台开发教程(七)Session处理
    多线程入门-创建线程
    MySQL数据库优化
    图解:从单个服务器扩展到百万用户的系统
  • 原文地址:https://www.cnblogs.com/Ivy-End/p/4319796.html
Copyright © 2011-2022 走看看