1430 - A Question of Time

#include <bits/stdc++.h>
using namespace std;
//fun()=3600*(2*h0-hx)+60*(2*m0-13*mx)+2*s0
//13*sx=fun()
//13*sx=fun()+360*120
//13*sx=fun()-360*120
const double eps=1e-10;
const double eps2=1e-3;
int h0,m0,s0;
int t1,t2;
int ans[50];
int len;
double fun(int tmp)
{
    double h,m,s;
    s=tmp%(13*60)/13.0;
    tmp/=13*60;
    m=tmp%60;
    h=tmp/60;
    double ang0=(30*h0)+(m0/2.0)+(s0/120.0);
    double ang1=(30*h)+(m/2.0)+(s/120.0);
    double ang2=(6*m)+(s/10.0);
    return ang1+ang2-2*ang0;
}
int bs(int l,int r,double x)
{
    int mid;
    while(r-l>1)
    {
        mid=(l+r)/2;
        double cmp=fun(mid)-x;
        if(cmp>=eps)
            r=mid;
        else
            l=mid;
    }
    if(t1<=l&&l<=t2&&fabs(fun(l)-x)<eps2)
        return l;
    else if(t1<=r&&r<=t2&&fabs(fun(r)-x)<eps2)
        return r;
    return -1;
}
void solve(int i)
{
    int l=i*46800,r=l+46800-1;
    int tmp=bs(l,r,0.0);
    if(tmp!=-1)
    {
        ans[len++]=tmp;
    }
    tmp=bs(l,r,360.0);
    if(tmp!=-1)
    {
        ans[len++]=tmp;
    }
    tmp=bs(l,r,-360.0);
    if(tmp!=-1)
    {
        ans[len++]=tmp;
    }
}
int main()
{
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    int t,Case=0;
    int h,m,s;
    scanf("%d",&t);
    while(t--)
    {
        len=0;
        scanf("%d:%d:%d",&h0,&m0,&s0);
        scanf("%d:%d:%d",&h,&m,&s);
        t1=((h*60+m)*60+s)*13;
        scanf("%d:%d:%d",&h,&m,&s);
        t2=((h*60+m)*60+s)*13;

        for(int i=0; i<12; i++)
        {
            solve(i);
        }

        sort(ans,ans+len);
        len=unique(ans,ans+len)-ans;
        printf("Case %d: %d\n",++Case,len);
        int mod;
        for(int i=0; i<len; i++)
        {
            mod=ans[i]%13;
            ans[i]/=13;
            s=ans[i]%60;
            ans[i]/=60;
            m=ans[i]%60;
            h=ans[i]/60;
            printf("%02d:%02d:%02d",h,m,s);
            if(mod)
                printf(" %d/13",mod);
            puts("");
        }
    }
}
时间: 2024-11-05 00:58:55

1430 - A Question of Time的相关文章

lightoj Basic Math 数论基础

这里是除去Beginners Problems后的部分 1020 - A Childhood Game 巴什博奕(Bash Game) #include<bits/stdc++.h> using namespace std; int main(void) { int t,Case=0; int n; char s[10]; scanf("%d",&t); while(t--) { scanf("%d%s",&n,&s); prin

light oj Basic Math 数论基础

这里是除去Beginners Problems后的部分 1020 - A Childhood Game 巴什博奕(Bash Game) #include<bits/stdc++.h> using namespace std; int main(void) { int t,Case=0; int n; char s[10]; scanf("%d",&t); while(t--) { scanf("%d%s",&n,&s); prin

是否通过技术任霆发够使肌肤

http://www.gome.com.cn/search?question=%E5%8F%B0%E5%B7%9E%E6%96%B0%E6%A1%A5%E9%95%87%e6%89%be%e5%b0%8f%e5%a7%90%e4%b8%8a%e9%97%a8%e6%9c%8d%e5%8a%a11858885v7572 http://www.gome.com.cn/search?question=%E5%8F%B0%E5%B7%9E%E6%96%B0%E6%A1%A5%E9%95%87%e6%89

榔举料昧卣pn5vu85bwh7a68krk

新华社瓦莱塔4月10日电(记者李拯宇 李佳)全国政协主席俞正声10日在前往非洲三国进行正式友好访问途中过境马耳他,在瓦莱塔会见马耳他议长法鲁贾. 俞正声说,中马保持长期友好关系,政治上相互信任,经济上密切合作,人文交流不断深化.中方感谢马方在中国撤侨行动中给予的支持和帮助.中方愿同马方一道,落实两国领导人达成的共识,弘扬中马传统友好,拓展在科技.渔业.旅游等领域互利合作,打造合作新亮点.中国全国政协愿与马耳他议会和社会各界保持密切交往,加强治国理政经验交流,为两国扩大务实合作营造良好环境,共同促

rwkj 1430 二分查找

#include<iostream>using namespace std;int n,k,a[10000]; int binsearch(int low,int high){ int i,len,s;while(low<high) { len=(high+low)/2; for(s=0,i=0;i<n;i++) s+=a[i]/len; if(s>k) low=len+1; else if(s<k) high=len-1; else return len; }}int

【Q&A】12C OCP 1z0-060 QUESTION 1: About Managing Temporary Tablespaces in a CDB

QUESTION 1 Your multitenant container (CDB) contains two pluggable databases (PDB), HR_PDB and ACCOUNTS_PDB, both of which use the CDB tablespace. The temp file is called temp01.tmp. A user issues a query on a table on one of the PDBs and receives th

hihoCoder 1430 : A Boring Problem(一琐繁题)

hihoCoder #1430 : A Boring Problem(一琐繁题) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 As a student of the school of electronics engineering and computer science in Peking University, Kyle took the course named Advanced Algebra in his freshma

nullcon HackIM 2016 -- Crypto Question 1

You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed their slik gowns on your beck. On onside your feelings are pulling you apart and another side you are called by the duty. The biggiest question is seX OR

Question about of Softlayer IPSec

http://w3.insidepacket.net/index.php/16-softlayer-ipsec-4 Recently, one Softlayer customer complained that they have issue when the servers on the corporate network talk to VM guest on Softlayer.  They found that their VM guests in Softlayer always s