• Time Zone


    Time Zone

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 2049    Accepted Submission(s): 636


    Problem Description
    Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
    Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone s.
     
    Input
    There are multiple test cases. The first line of input contains an integer T (1T106), indicating the number of test cases. For each test case:
    The first line contains two integers ab (0a23,0b59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0X,X.Y14,0Y9).
     
    Output
    For each test, output the time in the format of hh:mm (24-hour clock).
     
    Sample Input
    3
    11 11 UTC+8
    11 12 UTC+9
    11 23 UTC+0
     
    Sample Output
    11:11
    12:12
    03:23
     
    Source
     
     
    这题看起来不难,但是精度问题挺烦人的.
     
     1 #include <iostream>
     2 using namespace std;
     3 int n;
     4 int main(){
     5     scanf("%d",&n);
     6     int x,y;
     7     double z;
     8     char s[4];
     9     while(n--){
    10         scanf("%d%d%c%c%c%c%lf",&x,&y,&s[0],&s[1],&s[2],&s[3],&z);
    11         if(s[3]=='-'){
    12             z = -z;
    13         }
    14         double k = (z-8.0)*60.0;
    15         k += k>0?0.5:-0.5;
    16         int ans = (int)(k);
    17         ans +=(x*60+y);
    18         ans = (ans+1440)%1440;
    19         int xn = (ans/60)%24;
    20         int yn = ans%60;
    21         printf("%02d:%02d
    ",xn,yn);
    22     }
    23     return 0;
    24 }
     
     
  • 相关阅读:
    簡化SQL Insert、Update、Delete、Select的方法
    Microsoft SqlHelper Class
    EntLib5.0 日志应用程序块(logging) 使用与配置
    EnterpriseLibrary及Log4Net於WebConfig或AppConfig的相關配置
    LogHelper
    log4net使用详解
    Create\Move\Delte Folder\File
    Log4Net使用详解(续)
    DataSet 类(四)读写XML
    SqlDataAdapter类
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/9364746.html
Copyright © 2020-2023  润新知