HDOJ(HDU) 1491 Octorber 21st

Problem Description
HDU’s 50th birthday, on Octorber 21st, is coming. What an exciting day!! As a student of HDU, I always want to know how many days are there between today and Octorber 21st.So, write a problem and tell me the answer.Of course, the date I give you is always in 2006.

Input
The input consists of T test cases. The number of T is given on the first line of the input file.Following T lines, which represent dates, one date per line. The format for a date is “month day” where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31.All the date in the input are in 2006, you can assume that all the dates in the input are legal(合法).

Output
For each case, if the date is before Octorber 21st, you should print a number that between the date and Octorber 21st.If the day is beyond Octorber 21st, just print “What a pity, it has passed!”.If the date is just Octorber 21st, print”It’s today!!”.

Sample Input
7
10 20
10 19
10 1
10 21
9 1
11 11
12 12

Sample Output
1
2
20
It’s today!!
50
What a pity, it has passed!
What a pity, it has passed!

水题一个,弄清楚题意就知道了。
题目的意思是,今天是2006年10月21日。
(不是闰年,所以2月是28天)
输入的月 日 都是2006年的,也都是合法的。
如果输入的日期在10月21日之前,就输出那天到10月21日隔多少天。
如果输入10 21,就输出”It’s today!!”
如果输入的日期在10月21日之后,就输出”What a pity, it has passed!”

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        int time[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        while(t-->0){
            int a = sc.nextInt();
            int b = sc.nextInt();

            //用卫条件来防范
            //判断输入的是不是今天
            if(a==10&&b==21){
                System.out.println("It's today!!");
                continue;
            }

            //判断是不是输入10月21日之后的日期
            if(a>10||(a==10&&b>21)){
                System.out.println("What a pity, it has passed!");
                continue;
            }

            //判断是不是输入10月之后且10月21日之间的日期
            if(a==10){
                System.out.println(21-b);
                continue;
            }

            //剩下的就是10月之前的日期了。
            int tm=time[a]-b;
            for(int i=a+1;i<10;i++){
                tm+=time[i];
            }
            tm=tm+21;
            System.out.println(tm);
        }
    }

}
时间: 2024-10-22 04:55:29

HDOJ(HDU) 1491 Octorber 21st的相关文章

HDU 1491

Octorber 21st Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1500 Accepted Submission(s): 977 Problem Description HDU's 50th birthday, on Octorber 21st, is coming. What an exciting day!! As a stud

HDOJ/HDU 1161 Eddy&amp;#39;s mistakes(大写字母转换成小写字母)

Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for example "computer science" is written frequently "coMpUtEr scIeNce" by him, this mistakes lets Eddy's English teacher be extremely disco

HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)

Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game can be played by two or more t

HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)

Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No matter what's your major, the only thing I want to tell you is:"Treasure the college life and seize the time." Most people thought that the colle

HDOJ(HDU) 2109 Fighting for HDU(简单排序比较)

Problem Description 在上一回,我们让你猜测海东集团用地的形状,你猜对了吗?不管结果如何,都没关系,下面我继续向大家讲解海东集团的发展情况: 在最初的两年里,HDU发展非常迅速,综合各种ACM算法生成的老鼠药效果奇好,据说该药专对老鼠有效,如果被人误食了,没有任何副作用,甚至有传闻说还有健胃的效果,不过这倒没有得到临床验证.所以,公司的销量逐年递增,利润也是节节攀升,作为股东之一的公主负责财务,最近半年,她实在辛苦,多次因为点钞票造成双手抽筋而住院,现在在她面前你根本不要提到"

HDOJ(HDU) 2107 Founding of HDU(找最大值)

Problem Description 经过慎重的考虑,XHD,8600, LL,Linle以及RPG等ACM队员集体退役,甚至正在酝酿退学. 为什么?要考研?那也不用退学呀- 当然不是!真正的原因是他们想提前创业,想合伙成立一家公司,据说公司的名称都想好了,为了感谢多年的ACM集训队队长XHD,公司就叫海东集团(HaiDong Union),简称HDU.(对于这个公司名称,几个人私下里开玩笑说,外面的人看到HDU,可别以为是"胡捣集团",呵呵) 公司成立了,谁来做老大呢?这对于合伙的

HDOJ(HDU) 2500 做一个正气的杭电人(水~)

Problem Description 做人要有一身正气,杭电学子都应该如此.比如我们今天的考试就应该做到"诚信"为上. 每次考试的第一个题目总是很简单,今天也不例外,本题是要求输出指定大小的"HDU"字符串,特别地,为了体现"正气"二字,我们要求输出的字符串也是正方形的(行数和列数相等). Input 输入的第一行包含一个正整数N(N<=20),表示一共有N组数据,接着是N行数据,每行包含一个正整数M(M<=50),表示一行内有M个

HDOJ(HDU) 1465 不容易系列之一(错排)

Problem Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好"一件"事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. 话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的.比如,我高中的时候,就有一个神奇的女生,在英语考试的时候,竟然把40个单项选择题全部做错了!大家都学过概率论,应该知道出现这种情况的概率,所以至今我都觉得这是一件神奇的事情.如果套用一句经典的评语,我们可以这样总结

HDOJ(HDU) 2153 仙人球的残影(谜一样的题、、、)

Problem Description 在美丽的HDU,有一名大三的同学,他的速度是众所周知的,跑100米仅仅用了2秒47,在他跑步过程中会留下残影的哎,大家很想知道他是谁了吧,他叫仙人球,既然名字这样了,于是他的思想是单一的,他总是喜欢从一点出发,经过3次转折(每次向右转90°),回到出发点,而且呢,他每次转折前总是跑相同长度的路程,所以很多人都想知道如果用'1'算他跑步出发的第一个残影的话,那么回到起点的时候,他的残影是怎么样的呢?   Input 测试数据有多行,每一行为一个数N(1<=N