#include <iostream>
using namespace std;
static int minutes_from_reference(int day, int hour, int minute) {
int total = (day - 23) * 24 * 60 + hour * 60 + minute;
if (day > 29 || (day == 29 && hour >= 3)) {
total -= 60;
}
return total;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x, d, h, m;
cin >> x >> d >> h >> m;
int end_day;
if (x == 1) {
end_day = 24;
} else if (x == 2) {
end_day = 25;
} else if (x == 3) {
end_day = 26;
} else if (x == 4) {
end_day = 27;
} else {
end_day = 29;
}
int start_minutes = minutes_from_reference(d, h, m);
int finish_minutes = minutes_from_reference(end_day + 1, 0, 0);
cout << (finish_minutes - start_minutes) << '\n';
return 0;
}
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 31 32 33 34 35 36 37 38 | #include <iostream> using namespace std; static int minutes_from_reference(int day, int hour, int minute) { int total = (day - 23) * 24 * 60 + hour * 60 + minute; if (day > 29 || (day == 29 && hour >= 3)) { total -= 60; } return total; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int x, d, h, m; cin >> x >> d >> h >> m; int end_day; if (x == 1) { end_day = 24; } else if (x == 2) { end_day = 25; } else if (x == 3) { end_day = 26; } else if (x == 4) { end_day = 27; } else { end_day = 29; } int start_minutes = minutes_from_reference(d, h, m); int finish_minutes = minutes_from_reference(end_day + 1, 0, 0); cout << (finish_minutes - start_minutes) << '\n'; return 0; } |
English