define UP(i,x,y) for(i=x;i<=y;i++)

2017-2-16 09:25
请先登录。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define LS 2*i
#define RS 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define LL long long
#define N 25
#define MOD 19999997
#define INF 0x3f3f3f3f
#define EXP 1e-8

int t,hour,a,b,r,cas=1,m,s;
double minute,second;
char str[10];

void setA()
{
    if(r<=0)
        r+=360;
    minute = r/5.5;
    W(minute>=60)
    {
        hour++;
        minute-=60;
    }
    if(hour>12)
        hour-=12;
    m = (int)minute;
}

void setT()
{
    if(r>=0) r-=360;
    minute=r/5.5;
    hour--;
    W(minute<=-60)
    {
        hour--;
        minute+=60;
    }
    if(hour<=0)
        hour+=12;
    if(fabs(minute)<=EXP)
    {
        hour++;
        if(hour>12)
            hour-=12;
    }
    else minute+=60;
    m = (int)minute;
}

int main()
{
    scanf("%d",&t);
    W(t--)
    {
        scanf("%d%s%d",&a,str,&hour);
        b = 30*(12-hour);
        r = a-b;
        if(str[0]=='a')
            setA();
        else
            setT();
        second = (minute-(int)minute)*60;
        s = (int)(second+0.5);
        printf("Case %d: %d:%02d:%02d\n",cas++,hour,m,s);
    }


    return 0;
}
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define LS 2*i
#define RS 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define LL long long
#define N 25
#define MOD 19999997
#define INF 0x3f3f3f3f
#define EXP 1e-8

int t,hour,a,b,r,cas=1,m,s;
double minute,second;
char str[10];

void setA()
{
    if(r<=0)
        r+=360;
    minute = r/5.5;
    W(minute>=60)
    {
        hour++;
        minute-=60;
    }
    if(hour>12)
        hour-=12;
    m = (int)minute;
}

void setT()
{
    if(r>=0) r-=360;
    minute=r/5.5;
    hour--;
    W(minute<=-60)
    {
        hour--;
        minute+=60;
    }
    if(hour<=0)
        hour+=12;
    if(fabs(minute)<=EXP)
    {
        hour++;
        if(hour>12)
            hour-=12;
    }
    else minute+=60;
    m = (int)minute;
}

int main()
{
    scanf("%d",&t);
    W(t--)
    {
        scanf("%d%s%d",&a,str,&hour);
        b = 30*(12-hour);
        r = a-b;
        if(str[0]=='a')
            setA();
        else
            setT();
        second = (minute-(int)minute)*60;
        s = (int)(second+0.5);
        printf("Case %d: %d:%02d:%02d\n",cas++,hour,m,s);
    }


    return 0;
}