栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2106 Tick and Tick

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2106 Tick and Tick

#include<stdio.h>#include<algorithm>using namespace std;#define INF 0x7fffffffdouble D;struct node{    double l;    double r;}s[3][2];node interval(double a,double b){    node p;    if(a>0)    {        p.l=(D-b)/a;        p.r=(360-D-b)/a;    }    else    {        p.l=(360-D-b)/a;        p.r=(D-b)/a;    }    if(p.l>=p.r)    {        p.l=0;        p.r=0;    }    if(p.l<0)    p.l=0;    if(p.r>60)    p.r=60;    return p;}node jiao(node a,node b){    node p;    p.l=max(a.l,b.l);    p.r=min(a.r,b.r);    if(p.l>=p.r) p.l=p.r=0;    return p;}double solve(int h,int m){    double a,b;    a=1.0/120.0-1.0/10.0;    b=30*h+m/2.0-6.0*m;    s[0][0]=interval(a,b);    s[0][1]=interval(-a,-b);    a=1.0/120-6.0;    b=30*h+m/2.0;    s[1][0]=interval(a,b);    s[1][1]=interval(-a,-b);    a=0.1-6;    b=6*m;    s[2][0]=interval(a,b);    s[2][1]=interval(-a,-b);    node s1;    double res=0;    for(int i=0;i<2;i++)      for(int j=0;j<2;j++)         for(int k=0;k<2;k++)         {  s1=jiao(jiao(s[0][i],s[1][j]),s[2][k]);  res+=s1.r-s1.l;         }         return res;}int main(){    while(scanf("%lf",&D)!=EOF)    {        if(D==-1)        break;        double ans=0;        for(int i=0;i<12;i++)        { for(int j=0;j<60;j++) ans+=solve(i,j);        }        printf("%.3fn",100.0*ans/(60*60*12));    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/377310.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号