結果

問題 No.652 E869120 and TimeZone
ユーザー ミドリムシミドリムシ
提出日時 2018-02-23 22:34:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 877 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 70,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 12:18:34
合計ジャッジ時間 1,644 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

void output(int h, int m){
    if(h % 24 < 10 && m < 10){
        cout << "0" << h % 24 << ":0" << m << endl;
    }else if(h % 24 < 10){
        cout << "0" << h % 24 << ":" << m << endl;
    }else if(m < 10){
        cout << h % 24 << ":0" << m << endl;
    }else{
        cout << h % 24 << ":" << m << endl;
    }
}

int main(){
    int a, b;
    string S;
    cin >> a >> b >> S;
    a += 24 - 9;
    if(S[3] == '+'){
        double time_difference = stod(S.substr(4, S.size()));
        output(int(a * 60 + b + time_difference * 60) / 60, int(a * 60 + b + time_difference * 60) % 60);
    }else{
        double time_difference = stod(S.substr(4, S.size()));
        output(int(a * 60 + b - time_difference * 60 + 24 * 60) / 60, int(a * 60 + b - time_difference * 60 + 24 * 60) % 60);
    }
}
0