Tick and Tick
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5214 Accepted Submission(s): 1402
//基本是按这博客介绍的写法写的
http://blog.sina.com.cn/s/blog_81650692010138nr.html
//感觉这题真的好神奇+变态、解不等式
//还是这位哥写的好,用变量替换、省了很多代码
//要是我、知道思路后、就只有朴素的写法、然后自己都写的好烦、、、
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
double D;
double sum;
struct node
{
double l,r;
};
node ans[3][2];
node solve(double a,double b)
{
node qu;
if(a>0)
{
qu.l=(D-b)/a;
qu.r=(360-D-b)/a;
}
else
{
qu.l=(360-D-b)/a;
qu.r=(D-b)/a;
}
if(qu.l<0) qu.l=0;
if(qu.r>60) qu.r=60;
if(qu.l>=qu.r) { qu.l=qu.r=0;}
return qu;
}
node mer_g(node a,node b)
{
node q;
q.l=max(a.l,b.l);
q.r=min(a.r,b.r);
if(q.l>q.r) q.l=q.r=0;
return q;
}
int main()
{
int h,m;
int i,j,k;
double a1,a2,a3,b1,b2,b3;
while(scanf("%lf",&D),D!=-1)
{
sum=0;
node qu;
for(h=0;h<12;h++)
for(m=0;m<60;m++)
{
b1=m*6; a1=-5.9;
b2=30*h+(0.5-6)*m; a2=1.0/120-0.1;
b3=30*h+0.5*m; a3=1.0/120-6;
ans[0][0]=solve(a1,b1);ans[0][1]=solve(-a1,-b1);
ans[1][0]=solve(a2,b2);ans[1][1]=solve(-a2,-b2);
ans[2][0]=solve(a3,b3);ans[2][1]=solve(-a3,-b3);
for(i=0;i<2;i++)
for(j=0;j<2;j++)
for(k=0;k<2;k++)
{
qu=mer_g(mer_g(ans[0][i],ans[1][j]),ans[2][k]);
sum+=qu.r-qu.l;
}
}
printf("%.3lf\n",sum*100/43200);
}
return 0;
}