GRIDProblem code: CRZ02 |
In the University College of JNTUK Vizianagaram external lab examinations were being conducted. Management has decided to strictly prohibit the mal practices for that the management has decided to arrange cardboards of size nx2 to place in between two successive systems.
The construction of cardboard can be done only by using cardboard (Single cardboard) of size 1x2 (either dimensions).
Write a program that takes input N and outputs the number of different ways construction of required cardboard can be done. Output the answer mod 10^9 +7
Input
First line contains T (number of test cases)
Next T lines contain N.
Output
T lines with desired answer mod 1000000007 in each line.
Constraints
- 1<=T<=1000
- 1<=N<=10^6
Example
Input: 3 1 2 3 Output: 1 2 3
http://www.codechef.com/CDCN2014/
dp
大概是说用1*2的木板填充 N*2的位置
就考虑最后一步有两种可能
1.竖着放一个1*2
2.横着放两个1*2;
所以转移公式是
dp【i】 = dp【i - 1】 + dp【i - 2】;
打个表然后就输出就好 (貌似杭电上有这个类似的 回来也写写)
ac代码
http://paste.ubuntu.com/7199220/
CLOCKProblem code: CRZ04 |
In the University College of Engineering, an event called Code is being hosted. To participate in that event there is a preliminary round to be qualified. In this round, students are needed to find the angle between the Hour hand and Minute hand in a 12hr Clock at a particular instance of time(HH:MM), the best performing algorithm wins the place in the Code event. So help the Students in writing the program.
Input
First line contains T (number of test cases)
Next T lines contain HH, MM
Output
T lines producing the required answer rounded upto 1 decimal.
Constraints
- 00<=HH<=23
- 00<=MM<=59
- 1<=T<=1000
Example
Input:3
12 00
20 00
24 00
Output:
0.0
120.0
Invalid Time
题目链接
http://www.codechef.com/CDCN2014/problems/CRZ04
模拟
就是把电子表的时间转换成时钟的样子然后计算夹角
要注意 转换成时钟的时候 如果分针不是0位 那么时针也会转动的 要加上分针的大小才是真正的时针
ac代码