hdu 5387 Clock 简单数学

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<vector>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define nn 1000010
#define LL long long
#define ULL unsiged long long
//#define mod 0x7fffffff
#define mod 1100010
#define inf oxfffffffffff
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1


//        ((`'-"` `""-'`))
//         ) -  -  (
//        /  (o _ o)  \
//        \  ( 0 )  /
//       _'-.._ '=' _..-'_
//      /`;#'#'#. -. #'#'#;`\
//      \_))   '#'   ((_/
//      #.  ☆ ☆ ☆  .#
//      '#.  求 AC!  .#'
//       /'#.     .#'\
//       _\\'#.   .#'//_
//       (((___)'#'(___)))
struct node
{
    LL x,y;
};
LL gcd(LL a,LL b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
node gettime(node a,node b)
{
    node c;
    c.x=a.x*b.x;
    c.y=abs(a.y*b.x-b.y*a.x);
    LL k=gcd(c.x,c.y);
    c.x/=k;
    c.y/=k;
    if(c.y>c.x*180)
        c.y=c.x*360-c.y;
    return c;
}
int main()
{
    int t;
    node vs,vm,vh;
    vs.y=6,vs.x=1;
    vm.y=1,vm.x=10;
    vh.y=1,vh.x=120;
    scanf("%d",&t);

    while(t--)
    {
        LL h,m,s;
        scanf("%lld:%lld:%lld",&h,&m,&s);
        LL time=s+m*60+h*60*60;
        node ks,kh,km;
        ks.y=vs.y*time,ks.x=1;
        km.y=vm.y*time,km.x=10;
        kh.y=vh.y*time,kh.x=120;
        while(ks.y>=ks.x*360)
            ks.y-=ks.x*360;
        while(km.y>=km.x*360)
            km.y-=km.x*360;
        while(kh.y>=kh.x*360)
            kh.y-=kh.x*360;
        node ans1=gettime(kh,km);
        node ans2=gettime(kh,ks);
        node ans3=gettime(km,ks);
        if(ans1.y==0) printf("0 ");
        else if(ans1.x==1)
            printf("%lld ",ans1.y);
        else printf("%lld/%lld ",ans1.y,ans1.x);

        if(ans2.y==0) printf("0 ");
        else if(ans2.x==1)
            printf("%lld ",ans2.y);
        else printf("%lld/%lld ",ans2.y,ans2.x);

        if(ans3.y==0) printf("0 \n");
        else if(ans3.x==1)
            printf("%lld \n",ans3.y);
        else printf("%lld/%lld \n",ans3.y,ans3.x);
    }
    return 0;
}
计算出角速度,用角速度来计算。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值