多校8 1008 Clock

Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1320    Accepted Submission(s): 601

Problem Description

Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour.second hand
Notice that the answer must be not more 180 and not less than 0

Input

There are T(1≤T≤104) test cases
for each case,one line include the time

0≤hh<24,0≤mm<60,0≤ss<60

Output

for each case,output there real number like A/B.(A and B are coprime).if it‘s an integer then just print it.describe the angle between hour and minute,hour and second hand,minute and second hand.

Sample Input

4
00:00:00
06:00:00
12:54:55
04:40:00

Sample Output

0 0 0
180 180 0
1391/24 1379/24 1/2
100 140 120

Hint

每行输出数据末尾均应带有空格

  1 #include <stdio.h>
  2
  3 int main()
  4 {
  5     int T;
  6     int i,j,k,t;
  7     char s[10];
  8     scanf("%d",&T);
  9     while(T--)
 10     {
 11         t=0;
 12         scanf("%s",s);
 13         t=t+(s[7]-‘0‘)+(s[6]-‘0‘)*10;
 14         t=t+((s[4]-‘0‘)+(s[3]-‘0‘)*10)*60;
 15         t=t+((s[1]-‘0‘)+(s[0]-‘0‘)*10)*3600;
 16         //printf("t:%d\n",t);
 17         int a,A,b,B,c;
 18         c=(t*6)%360;
 19         b=t%3600,B=10;
 20         a=t%(120*360),A=120;
 21         //printf("a:%d b:%d c:%d\n",a,b,c);
 22
 23         int x,y;
 24         y=120;
 25         if(b*12-a>=0)
 26             x=b*12-a;
 27         else
 28             x=a-b*12;
 29         if(x>(120*180))
 30         {
 31             x=120*360-x;
 32         }
 33         if(x%120==0)
 34             printf("%d ",x/120);
 35         else
 36         {
 37             while(x%2==0 && y%2==0)
 38             {
 39                 x=x/2,y=y/2;
 40             }
 41             while(x%3==0 && y%3==0)
 42             {
 43                 x=x/3,y=y/3;
 44             }
 45             while(x%5==0 && y%5==0)
 46             {
 47                 x=x/5,y=y/5;
 48             }
 49             printf("%d/%d ",x,y);
 50         }
 51
 52         y=120;
 53         if(c*120-a>=0)
 54             x=c*120-a;
 55         else
 56             x=a-c*120;
 57         if(x>(120*180))
 58         {
 59             x=120*360-x;
 60         }
 61         if(x%120==0)
 62             printf("%d ",x/120);
 63         else
 64         {
 65             while(x%2==0 && y%2==0)
 66             {
 67                 x=x/2,y=y/2;
 68             }
 69             while(x%3==0 && y%3==0)
 70             {
 71                 x=x/3,y=y/3;
 72             }
 73             while(x%5==0 && y%5==0)
 74             {
 75                 x=x/5,y=y/5;
 76             }
 77             printf("%d/%d ",x,y);
 78         }
 79
 80         y=10;
 81         if(c*10-b>=0)
 82             x=c*10-b;
 83         else
 84             x=b-c*10;
 85         if(x>(10*180))
 86         {
 87             x=10*360-x;
 88         }
 89         //printf("x:%d\n",x);
 90         if(x%10==0)
 91             printf("%d ",x/10);
 92         else
 93         {
 94             while(x%2==0 && y%2==0)
 95             {
 96                 x=x/2,y=y/2;
 97             }
 98             while(x%5==0 && y%5==0)
 99             {
100                 x=x/5,y=y/5;
101             }
102             printf("%d/%d ",x,y);
103         }
104         printf("\n");
105     }
106     return 0;
107 }

时间: 2024-12-21 07:51:13

多校8 1008 Clock的相关文章

HDU 多校 VIII 1008 clock

Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 377    Accepted Submission(s): 200 Problem Description Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hou

hdu5387(2015多校8)--Clock(模拟)

题目链接:点击打开链接 题目大意:给出一个时间,问在钟表上这个时间的时候.时针和分针的角度,时针和秒针的角度.分针和秒针的角度.假设不是整数以分数的形式输出. 假设依照最小的格来算,那么: 1s对于秒针来说走1格,分针走12/720格.时针走1/720格. 1m对于分针来说走一个,时针走60/720格. 1h对于时针来说走5格. 计算给出的时间中时针,分针.秒针走的格数,相减得到差,每一格代表6度. 注意 1.整数的情况,当中有0,180和其他情况 2.取余 3.输出的角度0 <= j <=

【模拟,时针分针秒针两两夹角】【没有跳坑好兴奋】hdu - 5387 (多校#8 1008)

算是最好写的一道题了吧,最近模拟没手感,一次过也是很鸡冻o(* ̄▽ ̄*)o 注意事项都在代码里,没有跳坑也不清楚坑点在哪~ 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<vector> 5 #include<cmath> 6 #include<sstream> 7 #include<iostream> 8 using namesp

多校3 1008 Solve this interesting problem

Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1020    Accepted Submission(s): 279 Problem Description Have you learned something about segment tree? If not, don’

补题目录!

补补补!虽然感觉这目录会越来越长! 目录如下: 多校1: 1012/hdu5299(博弈).1009/hdu5296(数链剖分/其他).1006/hdu5293(不造) 多校2: 1004/hdu5303(贪心还是DP来的) 多校3: 1008/hdu5323(规律+模拟吧).1003/hdu5318(不造).1009/hdu5324(不造) 多校4: 1012/hdu5338(贪心+线段树之类的吧) 多校5: 1006/hdu5348.1010/hdu5352 (这场因为身体不舒服并没有打)

hdu5360||多校联合第6场1008 贪心

http://acm.hdu.edu.cn/showproblem.php?pid=5360 Problem Description There are n soda conveniently labeled by 1,2,-,n. beta, their best friends, wants to invite some soda to go hiking. The i-th soda will go hiking if the total number of soda that go hi

HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分)

HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6621 题意: 给你n个数,有m次询问 每次问你在区间[l,r]内 第k小的|\(a_i-p\)|是多少 题解: 主席树+二分 每次二分答案 如果p+mid到p-mid的值的个数大于k个的话,mid值就是可行了,然后缩小区间往左找即可 因为保证有解,所以二分出来的mid值就是答案了 que

2019杭电多校第三场 1008 K-th Closest Distance

题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6621 考虑主席树,我们先将所有值离散化之后建主席树.对于每个查询\(s,t,p,k\) 我们考虑二分一个值\(mid\),考虑当前区间内,\([p-mid, p+mid]\)的值有多少个,很显然这是符合单调性的,那么我们只需要每次判断即可.时间复杂度\(O(nlog^2n)\) #include <bits/stdc++.h> #define pii pair<int, int> #d

hdu 6127 : Hard challenge (2017 多校第七场 1008)(计算几何)

题目链接 题意:二维平面上有n个点(没有重叠,都不在原点,任意两点连线不过原点),每个点有一个权值,用一条过原点的直线把他们划分成两部分,使两部分的权值和的乘积最大.输出最大的乘积. 极角排序后,将原来(-pi,pi]区间的元素copy到(pi,3pi],用双指针维护一个角度差不超过pi的区间,记区间的权值和为sum1,用sum1*(sum-sum)更新ans #include<bits/stdc++.h> using namespace std; typedef long long LL;