codechef Code 2014 GRID,CLOCK

69 篇文章 0 订阅
16 篇文章 0 订阅

GRID

Problem 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/



CLOCK

Problem 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代码

http://paste.ubuntu.com/7199239/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AT89C2051是Atmel公司生产的一款8位单片机微控制器。在编程时,需要给AT89C2051提供一个时钟源,以便进行计时和同步操作。 时钟代码通常包括以下几个步骤: 1. 设置时钟源:AT89C2051可以使用外部时钟源或内部时钟源。如果使用外部时钟源,可以通过连接一个晶体振荡器或外部时钟信号源来提供时钟信号。如果使用内部时钟源,可以通过设置相关的时钟寄存器来选择合适的频率。 2. 初始化计时器:AT89C2051有一个可编程的定时计数器,用于进行计时操作。在编程之前,需要初始化计时器的相关寄存器,设置计时器的模式、计数方向和计数值等参数。 3. 启动计时器:通过设置相关的控制位,启动计时器开始计数。这样,计时器将按照设置的时钟源和计数模式进行计时。 4. 处理计时中断:AT89C2051可以在计时器达到特定计数值时触发中断。在处理计时中断时,可以执行相应的操作,如更新显示、保存数据等。在中断处理完成后,需要清除中断标志位,否则会一直触发中断。 5. 停止计时器:当计时器的计数完成或不再需要时,可以停止计时器的计数。通过设置相关的控制位,可以停止计时器,并将计数器的值清零,以备下一次计时使用。 总结来说,编写AT89C2051的时钟代码需要设置时钟源、初始化计时器、启动计时器、处理计时中断以及停止计时器等操作。通过这些代码,可以实现对AT89C2051的计时功能控制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值