HDU 1006 Tick and Tick 模拟
来源:互联网 发布:windows界面中新建 编辑:程序博客网 时间:2024/06/11 09:28
题意:就是问24小时中秒针,分针,时针的夹角两两大于d的时刻占总时刻的比重。
思路:模拟。我是求出秒针,分针,时针两两之间的速度,然后每次累加一个根据这个速度可以转180。 的区间,然后每次替换掉一个结束时刻最早的区间,直到有一个区间的开始时刻大于24∗60∗60s 。
坑点:时间不是连续的,不是1s,1s的走的,而是不停的在走,所以就不能计算出每一秒的相隔角度,再计算。
http://acm.hdu.edu.cn/showproblem.php?pid=1006
/********************************************* Problem : HDU 1006 Author : NMfloat InkTime (c) NM . All Rights Reserved .********************************************/#include <map>#include <set>#include <queue>#include <cmath>#include <ctime>#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>#define rep(i,a,b) for(int i = a ; i <= b ; i ++)#define rrep(i,a,b) for(int i = b ; i >= a ; i --)#define repE(p,u) for(Edge * p = G[u].first ; p ; p = p -> next)#define cls(a,x) memset(a,x,sizeof(a))#define eps 1e-8using namespace std;const int MOD = 1e9+7;const int INF = 0x3f3f3f3f;const int MAXN = 1e5;const int MAXE = 2e5;typedef long long LL;typedef unsigned long long ULL;int T,n,m,k;double degree;void input() {}double max_d(double a1,double a2,double a3) { double max_deg = a1; if(a2 > max_deg) max_deg = a2; if(a3 > max_deg) max_deg = a3; return max_deg;}double min_d(double a1,double a2,double a3) { double min_deg = a1; if(a2 < min_deg) min_deg = a2; if(a3 < min_deg) min_deg = a3; return min_deg;}void solve() { double v12 = 6 - 1.0/10; double v13 = 6 - 1.0/120; double v23 = 1.0/10 - 1.0/120; double base1,base2,base3,t1,t2,t3,t12,t13,t23,base12,base13,base23; t1 = base1 = degree / v12 ; t2 = base2 = degree / v13; t3 = base3 = degree / v23; t12 = 180 / v12; t13 = 180 / v13; t23 = 180 / v23; base12 = t12 - t1 ; base13 = t13 - t2; base23 = t23 - t3; double limit = 60 * 60 * 24; int cnt1 = 1 , cnt2 = 1, cnt3 = 1; double cro = 0; double ans = 0; while(1) { //区间t1-t12 t2-t13 t3-t23 if(t1 > limit || t2 > limit || t3 > limit) break; cro = min_d(t12,t13,t23) - max_d(t1,t2,t3); if(cro < 0) cro = 0; ans += cro; if(t12 <= t13 && t12 <= t23) { if(cnt1 % 2) { t1 = t12 ; t12 += base12 ; } else { t1 += 180 / v12 + base1; t12 = t1 + base12 ; } cnt1 ++; } else if(t13 <= t12 && t13 <= t23) { if(cnt2 % 2) { t2 = t13 ; t13 += base13 ; } else { t2 += 180 / v13 + base2; t13 = t2 + base13 ; } cnt2 ++; } else { if(cnt3 % 2) { t3 = t23; t23 += base23 ; } else { t3 += 180 / v23 + base3; t23 = t3 + base23 ; } cnt3 ++; } } //printf("%d %d %d\n",cnt1,cnt2,cnt3); printf("%.3lf\n",ans/limit*100);}int main(void) { //freopen("a.in","r",stdin); //scanf("%d",&T); //while(T--) { //while(~scanf("%d %d",&n,&m)) { while(scanf("%lf",°ree),degree+1) { input(); solve(); } return 0;}
0 0
- [HDU 1006] Tick and Tick 模拟题
- HDU 1006 Tick and Tick 模拟
- HDU 1006 Tick and Tick
- HDU 1006 Tick and Tick
- hdu 1006 Tick and Tick
- [HDU]1006 Tick and Tick
- HDU 1006 TICk and TICK
- HDU 1006 Tick and Tick
- Hdu 1006 Tick and Tick
- hdu 1006 Tick and Tick
- HDU 1006 Tick and Tick
- HDU:1006 Tick and Tick
- hdu 1006 Tick and Tick
- HDU 1006 Tick and Tick
- hdu 1006 Tick and Tick 模拟时钟注意时间连续性!
- HDU-1006 Tick and Tick(模拟 + 区间交集 + 数学)
- HDU 1006 Tick and Tick( 模拟题)
- hdu-Tick and Tick
- IOS吐槽狂人:卡顿和闪退
- 图像处理与计算机视觉基础,经典以及最近发展
- python 中__name__ = '__main__' 的作用
- C/C++ 浮点数比较问题
- 读二叉树有感
- HDU 1006 Tick and Tick 模拟
- btsync 分享资源
- 简单典型DFS---(解题报告)HDU1312---Red and Black
- FSM
- IOS吐槽狂人:找工程文件
- C语言指针 指针的赋值,变量的别名
- Java回炉之反射(一)
- Ubuntu15.04 安装卡在logo界面不动
- 自适应高度 — 按照文字 设置显示控件自适应 高度