zoukankan      html  css  js  c++  java
  • hdu 5387 Clock

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    int gcd(int u,int v)
    {
        if(u<v) swap(u,v);
        return v==0?u:gcd(v,u%v);
    }
    
    int abs(int x)
    {
        if(x<0) return -x;
        else return x;
    }
    
    int main()
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            int hh,mm,ss;
            scanf("%d:%d:%d",&hh,&mm,&ss);
            int ts,tm,th;
            ts=6*ss;
            tm=60*mm+ss;
            th=3600*(hh%12)+60*mm+ss;
            int difms=abs(10*ts-tm);
            int difhm=abs(12*tm-th);
            int difhs=abs(120*ts-th);
    
            if(difms>10*180) difms=10*360-difms;
            if(difhm>120*180) difhm=120*360-difhm;
            if(difhs>120*180) difhs=120*360-difhs;
    
            //printf("%d %d %d
    ",difhm,difhs,difms);
            if(difhm%120==0)
                printf("%d ",difhm/120);
            else
                printf("%d/%d ",difhm/gcd(difhm,120),120/gcd(difhm,120));
    
            if(difhs%120==0)
                printf("%d ",difhs/120);
            else
                printf("%d/%d ",difhs/gcd(difhs,120),120/gcd(difhs,120));
    
            if(difms%10==0)
                printf("%d 
    ",difms/10);
            else
                printf("%d/%d 
    ",difms/gcd(difms,10),10/gcd(difms,10));
    
        }
        return 0;
    }
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

  • 相关阅读:
    【XR-4】文本编辑器
    二十四、JMeter实战-Linux下搭建JMeter + Ant + Jenkins自动化框架
    Python 接口自动化
    Docker 部署 Tomcat
    CentOS7 查看 ip 地址
    Python
    Python接口自动化 -RESTful请求方法封装
    Python接口自动化
    Python
    xcode 编译webdriveragent
  • 原文地址:https://www.cnblogs.com/xryz/p/4847840.html
Copyright © 2011-2022 走看看