Gym - 100641A

原题:

https://vjudge.net/problem/Gym-100641A


#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define pi acos(-1.0)
#define INF 2147483647
using namespace std;
typedef long long ll;
typedef pair P;
int main()
{
    int a, b;
    int t;
    char str[10];
    scanf("%d", &t);
    for (int kase = 1; kase <= t; kase++)
    {
        scanf("%d%s%d", &a, str, &b);
        int h, m, s, x;
        if (str[0] == 'a')
        {
            x = (int)round((120.0 * (a -(12-b) * 30.0)) / 11.0);
            if(x<=0)
            {
                x = (int)round((120.0 * (360+a -(12- b) * 30.0)) / 11.0);
            }
            int cnt=(b-1)*3600+x;
            cnt=(cnt+12*3600)%(12*3600);
            h=cnt/3600+1;
            cnt%=3600;
            m=cnt/60;
            cnt%=60;
            s=cnt;
        }
        else
        {
            double ans = (120.0 * (-a + (12-b) * 30.0)) / 11.0;
            x=floor(ans+0.5);
            if(x<=0)
            {
                ans = (120.0 * (360-a + (12-b) * 30.0)) / 11.0;
                x=floor(ans+0.5);
            }
            int cnt=(b-1)*3600-x;
            cnt=(cnt+12*3600)%(12*3600);
            h=cnt/3600+1;
            cnt%=3600;
            m=cnt/60;
            cnt%=60;
            s=cnt;
        }
        printf("Case %d: %d:%02d:%02d\n", kase,h,m,s);
    }
    return 0;
}
/*
4
20 after 8
126 til 4
180 til 1
0 after 12
*/


你可能感兴趣的:(CodeForces)