#include <iostream>
using namespace std;
struct Time {
int d, h, m;
int toTotalMinutes() const {
return (d * 1440) + (h * 60) + m;
}
};
class DzielnyBajtazarSolver {
Time roundEnds[6];
public:
DzielnyBajtazarSolver() {
roundEnds[1] = {25, 0, 0};
roundEnds[2] = {26, 0, 0};
roundEnds[3] = {27, 0, 0};
roundEnds[4] = {28, 0, 0};
roundEnds[5] = {30, 0, 0};
}
int ileMinutDlaBajtazara(int x, int d, int h, int m) {
Time now = {d, h, m};
int startMinutes = now.toTotalMinutes();
int endMinutes = roundEnds[x].toTotalMinutes();
int difference = endMinutes - startMinutes;
if (x == 5) {
if (d < 29 || (d == 29 && h < 2)) {
difference -= 60;
}
}
return difference;
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x, h, m;
if (int d; cin >> x >> d >> h >> m) {
DzielnyBajtazarSolver solver;
cout << solver.ileMinutDlaBajtazara(x, d, h, m) << endl;
}
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <iostream> using namespace std; struct Time { int d, h, m; int toTotalMinutes() const { return (d * 1440) + (h * 60) + m; } }; class DzielnyBajtazarSolver { Time roundEnds[6]; public: DzielnyBajtazarSolver() { roundEnds[1] = {25, 0, 0}; roundEnds[2] = {26, 0, 0}; roundEnds[3] = {27, 0, 0}; roundEnds[4] = {28, 0, 0}; roundEnds[5] = {30, 0, 0}; } int ileMinutDlaBajtazara(int x, int d, int h, int m) { Time now = {d, h, m}; int startMinutes = now.toTotalMinutes(); int endMinutes = roundEnds[x].toTotalMinutes(); int difference = endMinutes - startMinutes; if (x == 5) { if (d < 29 || (d == 29 && h < 2)) { difference -= 60; } } return difference; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int x, h, m; if (int d; cin >> x >> d >> h >> m) { DzielnyBajtazarSolver solver; cout << solver.ileMinutDlaBajtazara(x, d, h, m) << endl; } return 0; } |
English