输入1000 5 期望输出04:30 但实际输出为07:30
自己的思路:
s——路程 v——速度
t——所需时间(总时间,单位为分钟)
m——所需时间(分钟) h——所需时间(小时)
#include <bits/stdc++.h>
using namespace std;
int main()
{
int s,v,t,m,h,M=50,H=7;
scanf("%d%d",&s,&v);
t=s/v;
if(s%v!=0) t++;
h=t/60;
if(h=0) m=t;
else m=t%60;
if(M-m<0)
(h=h-1,m=m+60,M=M-m);
else
M=M-m;
if(H-h<0)
(H=H+24,H=H-h);
else H=H-h;
if((H<10)&&(M<10))
printf("0%d:0%d",H,M);
else if((H>=10)&&(M>=10))
printf("%d:%d",H,M);
else if((H<10)&&(M>=10))
printf("0%d:%d",H,M);
else if((H>=10)&&(M<10))
printf("%d:0%d",H,M);
return 0;
}
}