Gym

来源:互联网 发布:淘宝买家秀震动棒 编辑:程序博客网 时间:2024/06/14 19:44

原题:

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


#include <iostream>#include <iomanip>#include <algorithm>#include <cstdio>#include <cstring>#include <queue>#include <deque>#include <stack>#include <string>#include <cmath>#include <vector>#include <utility>#include <set>#include <map>#include <sstream>#include <climits>//#pragma comment(linker, "/STACK:1024000000,1024000000")#define pi acos(-1.0)#define INF 2147483647using namespace std;typedef long long ll;typedef pair<int,int > 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;}/*420 after 8126 til 4180 til 10 after 12*/


原创粉丝点击