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);
}
}
}
HDOJ(HDU) 1491 Octorber 21st的更多相关文章
- hdu 1491 Octorber 21st
Octorber 21st Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- Octorber 21st
Octorber 21st Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- HDOJ(HDU).1412 {A} + {B} (STL SET)
HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...
- HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)
HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...
- HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)
HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...
- HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化)
HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数 ...
- HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化)
HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化) 题意分析 给出一系列的石头的数量,然后问石头能否被平分成为价值相等的2份.首先可以确定的是如果石头的价值总和为奇数的话,那 ...
- HDOJ(HDU).2191. 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 (DP 多重背包+二进制优化)
HDOJ(HDU).2191. 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 (DP 多重背包+二进制优化) 题意分析 首先C表示测试数据的组数,然后给出经费的金额和大米的种类.接着是每袋大米的 ...
- HDOJ(HDU).2159 FATE (DP 带个数限制的完全背包)
HDOJ(HDU).2159 FATE (DP 带个数限制的完全背包) 题意分析 与普通的完全背包大同小异,区别就在于多了一个个数限制,那么在普通的完全背包的基础上,增加一维,表示个数.同时for循环 ...
随机推荐
- 生成 JSON 数据
//build an info object and convert to json NSDictionary* info = [NSDictionary dictionaryWithObjectsA ...
- UITextView ios7
UITextView *textView2 = [[UITextView alloc]initWithFrame:CGRectMake(, textView1.frame.size.height + ...
- SSH端口修改
打开SSDH配置文件: vim /etc/ssh/sshd_config 添加端口号:Port 60000 重启服务:service sshd restart
- java集合框架03
Collections工具类的使用 public class News implements Comparable { private int id; //新闻编号 private String ti ...
- java多线程心得
多并发的时候,在什么情况下必须加锁?如果不加锁会产生什么样的后果. 加锁的场景跟java的new thread和Runnable的关系是什么? 看看java的concurrentMap源码. 还有sp ...
- Dragger代码实现
转自:http://www.apkbus.com/blog-705730-60436.html 在工程中引入Dagger 如果想使用Dagger的话,需要添加两个函数库: dependencies { ...
- 【转】setStyleSheet用法
[转自]http://blog.csdn.net/seanyxie/article/details/5925723 使用setStyleSheet来设置图形界面的外观: QT Style Sheets ...
- 洛谷 P1305 新二叉树
P1305 新二叉树 题目描述 输入一串完全二叉树,用遍历前序打出. 输入输出格式 输入格式: 第一行为二叉树的节点数n. 后面n行,每一个字母为节点,后两个字母分别为其左右儿子. 空节点用*表示 输 ...
- [转]C++智能指针的创建
zero 坐在餐桌前,机械的重复“夹菜 -> 咀嚼 -> 吞咽”的动作序列,脸上用无形的大字写着:我心不在焉.在他的对面坐着 Solmyr ,慢条斯理的吃着他那份午餐,维持着他一贯很有修养 ...
- 晓说智能指针shared_ptr为何可以实现跨模块分配和释放内存
最近做项目, 有个地方是外包人员写的, 其中有个函数,大致这样 void getInfo(std::shared_ptr<Info>& outInfo); 这个函数是一个dll(链 ...