codeforces 665A Buses Between Cities
简单题
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<algorithm> using namespace std; int a,ta,b,tb; int hh,mm; int f(int st,int en,int ss,int ee) { if(ee<=st) return 0; if(en<=ss) return 0; return 1; } int main() { scanf("%d%d",&a,&ta); scanf("%d%d",&b,&tb); scanf("%d:%d",&hh,&mm); int st=hh*60+mm; int en=hh*60+mm+ta; int t=0; int ans=0; while(1) { int ss=5*60+t*b; int ee=ss+tb; if(ss>=24*60) break; if(f(st,en,ss,ee)==1) ans++; t++; } printf("%d\n",ans); return 0; }