#include <iostream>
#include <vector>
using namespace std;
int endDays[5] = {25, 26, 27, 28, 30};
int timeToMinutes(int day, int hour, int min) {
if ((day == 29 && hour >= 3) || (day > 29)) {
hour--;
}
hour += 24 * day;
min += 60 * hour;
return min;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int x, d, m, h;
cin >> x >> d >> h >> m;
cout << timeToMinutes(endDays[x - 1], 0, 0) - timeToMinutes(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 | #include <iostream> #include <vector> using namespace std; int endDays[5] = {25, 26, 27, 28, 30}; int timeToMinutes(int day, int hour, int min) { if ((day == 29 && hour >= 3) || (day > 29)) { hour--; } hour += 24 * day; min += 60 * hour; return min; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x, d, m, h; cin >> x >> d >> h >> m; cout << timeToMinutes(endDays[x - 1], 0, 0) - timeToMinutes(d, h, m); } |
English