UVA 10371 POJ 2351 ZOJ 1916 Time Zone(模拟)

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<ctype.h>
#include<stack>
#include<math.h>
#include <string>
#include<algorithm>
using namespace std;

typedef unsigned long long ULL;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);

    map<string,double> m;
    m["UTC"]=0;
    m["GMT"]=0;
    m["BST"]=1;
    m["IST"]=1;
    m["WET"]=0;
    m["WEST"]=1;
    m["CET"]=1;
    m["CEST"]=2;
    m["EET"]=2;
    m["EEST"]=3;
    m["MSK"]=3;
    m["MSD"]=4;
    m["AST"]=-4;
    m["ADT"]=-3;
    m["NST"]=-3.5;
    m["NDT"]=-2.5;
    m["EST"]=-5;
    m["EDT"]=-4;
    m["CST"]=-6;
    m["CDT"]=-5;
    m["MST"]=-7;
    m["MDT"]=-6;
    m["PST"]=-8;
    m["PDT"]=-7;
    m["HST"]=-10;
    m["AKST"]=-9;
    m["AKDT"]=-8;
    m["AEST"]=10;
    m["AEDT"]=11;
    m["ACST"]=9.5;
    m["ACDT"]=10.5;
    m["AWST"]=8;

    int n;

    string times,ap,one,two;
    int time,mint;
    int sumtime;
    cin>>n;
    while(n--)
    {
        time=mint=0;
        cin>>times;
        if(isdigit(times[0]))
        {
            int i=0;
            while(times[i]!=':')
            {
                time=time*10+(times[i]-'0');
                i++;
            }
            i++;
            while(i<times.size())
            {
                mint=mint*10+(times[i]-'0');
                i++;
            }
            cin>>ap;
            if(ap[0]=='a')
                sumtime=(time%12)*60+mint;
            else
                sumtime=(time%12)*60+mint+12*60;
        }
        else
            if(times=="noon")
                sumtime=12*60;
            else
                sumtime=0;
        int sumtime2;
        cin>>one>>two;
        sumtime2=sumtime-(int)(m[one]*60)+(int)(m[two]*60);
        time=(sumtime2+24*60)%(24*60);
        if(time==0)
            cout<<"midnight"<<endl;
        else if(time==12*60)
            cout<<"noon"<<endl;
        else
        {
            if(time>12*60)
            {
                printf("%d:%02d ",(int)(time/60)%12==0?12:(time/60)%12,time%60);
                cout<<"p.m."<<endl;
            }
            else
            {
                printf("%d:%02d ",(int)(time/60)%12==0?12:(time/60)%12,time%60);
                cout<<"a.m."<<endl;
            }


        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值