HDU 5387 Clock (MUT#8 模拟)
来源:互联网 发布:在淘宝联盟怎么推广 编辑:程序博客网 时间:2024/05/05 01:14
【题目链接】:click here~~
【题目大意】给定一个时间点,求时针和分针夹角,时针和秒针夹角,分针和秒针夹角
模拟题,注意细节
代码:
#include<bits/stdc++.h>using namespace std;inline int read(){ int c=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){c=c*10+ch-'0';ch=getchar();} return c*f;}int gcd(int a,int b){return b==0?a:gcd(b,a%b);}int main(){ int t,h,m,s; t=read(); while(t--){ scanf("%d:%d:%d",&h,&m,&s); h%=12; m%=60; s%=60; int ss=s*720; //秒针走过的角度 int mm=720*m+12*s; //分针走过的角度 int hh=3600*h+60*m+s; //时针走过的角度 //计算角度之差 int hm=abs(hh-mm); int hs=abs(hh-ss); int ms=abs(mm-ss); //判断 hm=min(hm,120*360-hm); hs=min(hs,120*360-hs); ms=min(ms,120*360-ms); //取最大公约数 int ghm=gcd(hm,120); int ghs=gcd(hs,120); int gms=gcd(ms,120); if(ghm==120) cout<<hm/120; else cout<<hm/ghm<<"/"<<120/ghm; if(ghs==120) cout<<" "<<hs/120<<" "; else cout<<" "<<hs/ghs<<"/"<<120/ghs<<" "; if(gms==120) cout<<ms/120<<" "<<endl; else cout<<ms/gms<<"/"<<120/gms<<" "<<endl; } return 0;}
0 0
- HDU 5387 Clock (MUT#8 模拟)
- HDU 5386 Cover (MUT #8 模拟暴力)
- HDU 5387 Clock(模拟)
- HDU 5387 Clock // 模拟
- HDU 5402 Travelling Salesman Problem (MUT#9 暴力模拟)
- HDU 5387(2015多校8)-Clock(模拟)
- HDU 5387 Clock(分数类+模拟)
- HDU 1209 Clock(模拟)
- HDU 5705 Clock(模拟)
- HDU 5389 Zero Escape (MUT#8 dp优化)
- HDU 5387 Clock(模拟)——(多校练习8)
- HDU 5387 Clock(简单模拟)——2015 Multi-University Training Contest 8
- HDU 1393 Weird Clock (模拟)
- hdu 5387 Clock(分数)
- 2015多校第8场 HDU 5387 Clock 模拟,计算时钟指针角度
- hdu5387(2015多校8)--Clock(模拟)
- HDU 5396 Expression (MUT#9 区间DP)
- MUT
- HDU 1247 Hat’s Words(字典树简单应用)
- Android开发大全
- Linux环境Nginx安装多版本PHP
- 排序问题思考
- abstract class和interface的区别 及模板方法设计模式
- HDU 5387 Clock (MUT#8 模拟)
- 组播基础知识
- android 使用SharedPreferences保存list数据
- Android性能优化典范 - 第3季
- 对频率论(Frequentist)方法和贝叶斯方法(Bayesian Methods)的一个总结
- Android L——RecyclerView,CardView的导入和使用
- JToggleButton的重构状态以及ButtonGroup的使用
- 海水淡化膜:反渗透预处理对于海水淡化技术必要性
- 高斯滤波核计算 C版