杭电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))); } } }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步