#include <iostream>
#include <array>
using namespace std;
using ll = long long;
constexpr ll hours_in_day = 24;
constexpr ll minutes_in_hour = 60;
constexpr ll getTime(ll day, ll hour, ll minute) {
return (day * hours_in_day + hour - ((day == 29 && hour >= 3) || day > 29)) * minutes_in_hour + minute;
}
constexpr array<ll, 5> round_end = {
getTime(25, 0, 0),
getTime(26, 0, 0),
getTime(27, 0, 0),
getTime(28, 0, 0),
getTime(30, 0, 0),
};
int main() {
std::ios_base::sync_with_stdio(0);
cin.tie(0);
ll x, d, h, m;
cin >> x >> d >> h >> m;
cout << round_end[x - 1] - getTime(d, h, m);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <iostream> #include <array> using namespace std; using ll = long long; constexpr ll hours_in_day = 24; constexpr ll minutes_in_hour = 60; constexpr ll getTime(ll day, ll hour, ll minute) { return (day * hours_in_day + hour - ((day == 29 && hour >= 3) || day > 29)) * minutes_in_hour + minute; } constexpr array<ll, 5> round_end = { getTime(25, 0, 0), getTime(26, 0, 0), getTime(27, 0, 0), getTime(28, 0, 0), getTime(30, 0, 0), }; int main() { std::ios_base::sync_with_stdio(0); cin.tie(0); ll x, d, h, m; cin >> x >> d >> h >> m; cout << round_end[x - 1] - getTime(d, h, m); } |
English