#include <bits/stdc++.h>
using namespace std;
struct Date{
int day;
int h;
int m;
void addHour(){
h++;
if(h == 24){
h = 0;
day++;
}
if(h == 2 && day == 29){
h = 3;
}
}
void addMinute(){
m++;
if(m == 60){
m = 0;
addHour();
}
}
bool operator==(Date d){
return (day == d.day && h == d.h && m == d.m);
}
void coutD(){
cout << day << " " << h << " " << m << "\n";
}
};
int timeForTo(Date s, Date e){
int ans = 0;
while(!(s == e)){
ans++;
s.addMinute();
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int rund;
Date start;
cin >> rund >> start.day >> start.h >> start.m;
Date endR = {rund + 24 + (rund == 5), 0, 0};
cout << timeForTo(start, endR);
}
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 54 55 56 57 58 59 60 61 | #include <bits/stdc++.h> using namespace std; struct Date{ int day; int h; int m; void addHour(){ h++; if(h == 24){ h = 0; day++; } if(h == 2 && day == 29){ h = 3; } } void addMinute(){ m++; if(m == 60){ m = 0; addHour(); } } bool operator==(Date d){ return (day == d.day && h == d.h && m == d.m); } void coutD(){ cout << day << " " << h << " " << m << "\n"; } }; int timeForTo(Date s, Date e){ int ans = 0; while(!(s == e)){ ans++; s.addMinute(); } return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int rund; Date start; cin >> rund >> start.day >> start.h >> start.m; Date endR = {rund + 24 + (rund == 5), 0, 0}; cout << timeForTo(start, endR); } |
English