hdu5387(2015多校8)--Clock(模拟)
题目链接:点击打开链接
题目大意:给出一个时间,问在钟表上这个时间的时候。时针和分针的角度,时针和秒针的角度。分针和秒针的角度。假设不是整数以分数的形式输出。
假设依照最小的格来算,那么:
1s对于秒针来说走1格,分针走12/720格。时针走1/720格。
1m对于分针来说走一个,时针走60/720格。
1h对于时针来说走5格。
计算给出的时间中时针,分针。秒针走的格数,相减得到差,每一格代表6度。
注意
1、整数的情况,当中有0,180和其他情况
2、取余
3、输出的角度0 <= j <= 180,所以要注意选小的角。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
struct time{
int x , y ;
}h , m , s , temp ;
int gcd(int a,int b) {
return b == 0 ? a : gcd(b,a%b) ;
}
void f(time temp) {
if( temp.x%temp.y == 0 ) {
temp.x /= temp.y ;
temp.x %= 360 ;
if( temp.x%360 == 0 )
printf("0 ") ;
else if( temp.x%180 == 0 )
printf("180 ") ;
else
printf("%d ", min(temp.x,360-temp.x) ) ;
}
else{
temp.x %= (360*120) ;
temp.x = min(temp.x,360*120-temp.x) ;
int k = gcd(temp.x,temp.y) ;
printf("%d/%d ", temp.x/k, temp.y/k) ;
}
}
int main() {
int t , a , b , c ;
scanf("%d", &t) ;
while( t-- ) {
scanf("%d:%d:%d", &a, &b, &c) ;
h.x = 3600*a + 60*b + c ;
m.x = 720*b + 12*c ;
s.x = 720*c ;
temp.x = abs(h.x-m.x) ;
temp.y = 120 ;
f(temp) ;
temp.x = abs(h.x-s.x) ;
f(temp) ;
temp.x = abs(m.x-s.x) ;
f(temp) ;
printf("\n") ;
}
return 0 ;
}
hdu5387(2015多校8)--Clock(模拟)的更多相关文章
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- hdu5379||2015多校联合第7场1011 树形统计
pid=5379">http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- 【简单dp+模拟】hdu-5375(2015多校#7-1007)
给你一个二进制数,,每一位有一个权值,让你转格雷码,求所对应格雷码位为1的权值的和:二进制位中的某些位为?,你需要给这些问号赋值使得到的和最大. 首先你得知道二进制转格雷码的规则,即格雷码位为[二进制 ...
- hdu 5289 Assignment(2015多校第一场第2题)RMQ+二分(或者multiset模拟过程)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5289 题意:给你n个数和k,求有多少的区间使得区间内部任意两个数的差值小于k,输出符合要求的区间个数 ...
- HDU 5373(2015多校7)-The shortest problem(模拟%11)
题目地址:pid=5373">HDU 5373 题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除. 思路:就是 ...
- 2015 多校联赛 ——HDU5402(模拟)
For each test case, in the first line, you should print the maximum sum. In the next line you should ...
- 2015 多校联赛 ——HDU5373(模拟)
Problem Description In this problem, we should solve an interesting game. At first, we have an integ ...
- hdu 5308 (2015多校第二场第9题)脑洞模拟题,无语
题目链接:http://acm.hdu.edu.cn/listproblem.php?vol=44 题意:给你n个n,如果能在n-1次运算之后(加减乘除)结果为24的输出n-1次运算的过程,如果不能输 ...
随机推荐
- scrapy怎么设置带有密码的代理ip base64.encodestring不能用 python3.5,base64库里面的encodestring()被换成了什么?
自己写爬虫时买的代理ip有密码,在网上查了都是下面这种: 1.在Scrapy工程下新建"middlewares.py": import base64 # Start your mi ...
- django前端渲染多对多关系(比如一本书的作者有哪些)
自己遇到的问题是,前端渲染不出多对多关系,咨询Yuan后解决,特此记录. urls.py from django.conf.urls import url from book import views ...
- bzoj 1038 瞭望塔 半平面交+分段函数
题目大意 给你一座山,山的形状在二维平面上为折线 给出\((x_1,y_1),(x_2,y_2)...(x_n,y_n)\)表示山的边界点或转折点 现在要在\([x_1,x_n]\)(闭区间)中选择一 ...
- hdu 1277 AC自动机
全文检索 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- hdu 6119 小小粉丝度度熊
小小粉丝度度熊 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 开始学习es6(一) 搭建个es6的开发环境
1.开始学习es6 如果想在浏览器跑es6 需要给es6个环境 因为一直用vue-cli全家桶 这样虽然方便 但如果用es6需要跑起个vue全家桶 于是想到可以用gulp搭建个开发环境 首先需要1. ...
- pexpect模块
pexpect用来启动子程序,使用正则表达式对程序输出做出特定响应,以此实现与其自动交互的python模块,当然我们可以使用他来做ssh登陆,ssh模块登陆还有一个基于python实现远程连接,用于s ...
- configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. 一.错误发生情景: 在安装gcc时,执行.c ...
- hdu 1099(数学)
Lottery Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- AC日记——【模板】最小费用最大流 P3381
题目描述 如题,给出一个网络图,以及其源点和汇点,每条边已知其最大流量和单位流量费用,求出其网络最大流和在最大流情况下的最小费用. 输入输出格式 输入格式: 第一行包含四个正整数N.M.S.T,分别表 ...