#include <iostream>
using namespace std;
const int minutes_in_day = 24*60;
int to_minutes(int d, int h, int m){
return d*minutes_in_day + h*60 + m;
}
const int first_round_start = to_minutes(23, 12, 0);
const int time_change = to_minutes(29, 2, 0);
int round_duration(int x){
if (x == 5) return 2.5 * minutes_in_day;
return 1.5 * minutes_in_day;
}
int get_round_end(int x){
return first_round_start + minutes_in_day * (x - 1) + round_duration(x);
}
int check_if_time_decreased(int start, int end){
if (start < time_change && end >= time_change) return end - start - 60;
return end - start;
}
int main(){
int x, d, h, m;
cin >> x >> d >> h >> m;
int start = to_minutes(d, h, m);
int end = get_round_end(x);
cout << check_if_time_decreased(start, end) << endl;
}
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 | #include <iostream> using namespace std; const int minutes_in_day = 24*60; int to_minutes(int d, int h, int m){ return d*minutes_in_day + h*60 + m; } const int first_round_start = to_minutes(23, 12, 0); const int time_change = to_minutes(29, 2, 0); int round_duration(int x){ if (x == 5) return 2.5 * minutes_in_day; return 1.5 * minutes_in_day; } int get_round_end(int x){ return first_round_start + minutes_in_day * (x - 1) + round_duration(x); } int check_if_time_decreased(int start, int end){ if (start < time_change && end >= time_change) return end - start - 60; return end - start; } int main(){ int x, d, h, m; cin >> x >> d >> h >> m; int start = to_minutes(d, h, m); int end = get_round_end(x); cout << check_if_time_decreased(start, end) << endl; } |
English