hoj 1010 The Angle

The interval angle between the hour hand and the minute hand is always among 0 degree and 180 degree(including 0 and 180 degree). For example, when it‘s 12 o‘clock, the angle of the two hands is 0 while 6:00 is 180 degree. Try to calculate any degree when it‘s between 12:00 to 11:59.

Input
The input data are of various situations. Every team consists of two numbers : the first number stands for the hour(great than 0 and less than or equal to 12) and second represents the minute( among [0, 59]). The input ends when the two numbers are both zeros.
Output
Print out the minimum angle between the two hands with the normal time form outputed.
Input Sample

12 0
12 30
6 0
3 0
0 0

Output Sample

At 12:00 the angle is 0.0 degrees.
At 12:30 the angle is 165.0 degrees.
At 6:00 the angle is 180.0 degrees.
At 3:00 the angle is 90.0 degrees.
 
钟表模拟题,比较水…
#include <stdio.h>
#include <math.h>
int main()
{
    double mAngle,hAngle,a,b,begin;
    int hour,minute;
    while(scanf("%d %d",&hour,&minute)==2)
    {
        if((hour==0&&minute==0)||minute>59||hour>12)
            break;
        a=(double)minute/60;                     //a代表minute给hAngle所带来的增量
        begin=(double)hour;
        if(begin==12)
            begin=0;
        begin+=a;
        hAngle=30*begin;
        mAngle=(double)minute*360/60;
        b=fabs(mAngle-hAngle);
        if(b>180)
         b=360-b;
        printf("At %d:%02d the angle is %.1lf degrees.\n",hour,minute,b);
    }
    return 0;
}
时间: 2024-08-09 22:01:10

hoj 1010 The Angle的相关文章

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

【hoj】2608 assemble 二分法

/* 思路:本文要求找到满足预算的最好配置的组件,组装计算机,所以可以是按照 *计算机的quantity以标准去查找相应的组件,就可以应用二分法,将每一种组件中的类型都按照质量排序 *选择满足整体质量的要求的情况下的最低价格 */ #include<iostream> #include<string> #include<string.h> #include<algorithm> #include<cstdio> #include<cstri

LightOJ 1010 Knights in Chessboard (规律)

题意:给定一个m*n的棋盘,问最多放多少个马,使得他们不相互攻击. 析:很明显可以从上图看出来了马放在白格,或者黑格,不会攻击,不过行或者列为1,2时是特殊的,我们只要特殊判断一下就行了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cm

1010 求个最大值

1010: 求个最大值 时间限制: 1 Sec  内存限制: 128 MB提交: 231  解决: 39[提交][状态][讨论版] 题目描述 给出 n(1 <= n <= 200000)个数字 ai(1 <= ai <= 1000000),i 为数字的下标,按输入顺序从 1 开始编号一直到 n,求满足 ai >= aj 的最大的 ai % aj. 输入 第一行一个数字 n,第二行 n 个整数. 输出 题目要求的最大值. 样例输入 2 2 3 样例输出 1 提示

BZOJ - 1010【斜率优化DP】

1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9961  Solved: 4056[Submit][Status][Discuss] Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压 缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1...N的N件玩具,第i件玩具经过 压缩后变成一维长度为Ci.为了方便整理

BZOJ 1010: [HNOI2008]玩具装箱toy [DP 斜率优化]

1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9812  Solved: 3978[Submit][Status][Discuss] Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1...N的N件玩具,第i件玩具经过压缩后变成一维长度为Ci.为了方便整理,P

HOJ 1797 Red and Black

传送门  http://acm.hit.edu.cn/hoj/problem/view?id=1797 总体的思路是遍历可以到达的' . ',将其对应的vis数组化为1,然后统计所有为1的vis项; ①常用的加边法,防止越界 ②初始化,不然两次相同的输入得到的结果会不同,由于是二维数组,能力有限,只好在结尾初始化,为下次输入做准备 ③结束条件,递归函数一定要先写好结束条件,不然会炸 ④上下左右四向移动 ⑤直接递归函数调用自身 1 #include <stdio.h> 2 #include &l

NBUT 1010 魔法少女(DP)

[1010] 魔法少女 时间限制: 1000 ms 内存限制: 65535 K 问题描述 前些时间虚渊玄的巨献小圆着实火了一把. 在黑长直(小炎)往上爬楼去对抗魔女之夜时,她遇到了一个问题想请你帮忙. 因为魔女之夜是悬浮在半空的,所以她必须要爬楼,而那座废墟一共有n层,而且每层高度不同,这造成小炎爬每层的时间也不同.不过当然,小炎会时间魔法,可以瞬间飞过一层或者两层[即不耗时].但每次瞬移的时候她都必须要至少往上再爬一层(在这个当儿补充魔力)才能再次使用瞬移.爬每单位高度需要消耗小炎1秒时间.

搜索(DLX):HOJ 1017 - Exact cover

1017 - Exact cover Time Limit: 15s Memory Limit: 128MB Special Judge Submissions: 6751 Solved: 3519 Description There is an N*M matrix with only 0s and 1s, (1 <= N,M <= 1000). An exact cover is a selection of rows such that every column has a 1 in e