杭电ACM2076--夹角有多大(题目已修改,注意读题)

杭电ACM2076--夹角有多大(题目已修改,注意读题)

http://acm.hdu.edu.cn/showproblem.php?pid=2076

 

思路很简单。直接贴代码。过程分析有点耗时间。

 

// #include <stdio.h>
// #include <math.h>
// int main()
// {
// 	int t;
// 	double h,m,s;
// 	//int h,m,s;
// 	int z;
// 	scanf("%d",&t);
// 	while (t--)
// 	{
// 		z = 0;
// 		scanf("%lf%lf%lf",&h,&m,&s);
// 		//scanf("%d%d%d",&h,&m,&s);
// 		//printf("asdf");
// 
// 		z = (int)((h+(m+s/60)/60)*360/12-((m+s/60)*360/60)-0.5);
// 		if (z<0)
// 		{
// 			z = -z;
// 		}
// 		else if (z>180)
// 		{
// 			z = 360-z;
// 		}
// 		printf("%d\n",z);
// 	}
// 	return 0;
// }


/*
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
//#include<map>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
using namespace std;
const double pi = acos(-1.);
int a[100010];
int main()
{
    int t;
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            int h,s,m;
            double ans1,ans2;
            scanf("%d%d%d",&h,&m,&s);
            if(h>=12) h-=12;
            ans1=(h+(m*1.0/60)+(s*1.0/3600))*30;//先算时针夹角
            ans2=(m+(s*1.0/60))*6;//再算分针
            if(fabs(ans1-ans2)>180)
            {
                printf("%d\n",int(360-(fabs(ans1-ans2))));
            }
            else
            {
                printf("%d\n",int(fabs(ans1-ans2)));
            }
        }
    }
    return 0;
}
*/

#include <stdio.h>
#include <math.h>
int main()
{
	int t;
	int h,s,m;
	double ans1,ans2;
	scanf("%d",&t);
	while (t--)
	{
		scanf("%d%d%d",&h,&m,&s);
		if (h>=12) h = h-12;
		ans1 = (h+(m*1.0/60)+(s*1.0/3600))*30;
		ans2 = (m+(s*1.0/60))*6;
		if(fabs(ans1-ans2)>180)
		{
			printf("%d\n",int(360-(fabs(ans1-ans2))));
		}
		else
		{
			printf("%d\n",int(fabs(ans1-ans2)));
		}
	}
}


 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值