直接用24*60(一天的总时间)减需花费时间,再分类,注意补0
#include<iostream>
#include<string>
using namespace std;
int main() {
int s,v,ans;
scanf("%d%d",&s,&v);
if(s%v) ans = s/v+1;
else ans=s/v;
ans+=10;
//ans为花费时间
int time = 24*60;//总共可以提前1天的时间
ans = time-ans;//从前一天8点开始经过的时间
int hh = ans/60;
int mm = ans%60;
if(hh<2){
if(mm<10){
printf("0%d:0%d",8+hh,mm);
}else{
printf("0%d:%d",8+hh,mm);
}
}else if(hh<16){
if(mm<10){
printf("%d:0%d",8+hh,mm);
}else{
printf("%d:%d",8+hh,mm);
}
}
else {
if(mm<10){
printf("0%d:0%d",hh-16,mm);
}else{
printf("0%d:%d",hh-16,mm);
}
}
return 0;
}