LeetCode Weekly Contest 287
問題文
省略
省略
C++に変換後のコードはこちら
#define main dummy_main
{}
#undef main
class Solution {
public:
int convertTime(string current, string correct) {
int res = 0, tmp = 0, arr[4] = {60, 15, 5, 1};
tmp += atoi(correct.substr(0,2).c_str()) * 60;
tmp -= atoi(current.substr(0,2).c_str()) * 60;
tmp += atoi(correct.substr(3,2).c_str());
tmp -= atoi(current.substr(3,2).c_str());
if(tmp < 0) tmp += 24 * 60;
rep(i,4) res += tmp / arr[i], tmp %= arr[i];
return res;
}
};
Current time: 2024年05月19日05時54分42秒
Last modified: 2022年04月10日17時57分37秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)