题解:P5707 【深基2.例12】上学迟到
先要计算总时间,走路的时间是
附上代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,v;
cin>>s>>v;
int t1=(s+v-1)/v+10;// 计算总时间
int t2=8*60-t1; // 8:00 转换成分钟数,8*60=480分钟。出发时间 = 480-t1
if(t2<0)t2+=24*60;// 处理时间跨天的情况
int a=t2/60,b=t2%60;// 将分钟数转换为小时和分钟
printf("%02d:%02d",a,b);
return 0;
}
感觉这个是最短的代码