kajews @ 2024-10-14 19:12:57
以下是我的代码:
#include<stdio.h>
#include<math.h>
int main()
{
int s,v,t,m,m1,m2;
scanf("%d%d",&s,&v);
t=ceil(s*1.0/v)+10;
if(t<8*60){
m=8*60-t;
m1=m/60;
m2=m%60;
if(m2>=10)
printf("0%d:%d",m1,m2);
else if(m2<10)
printf("0%d:0%d",m1,m2);
}else if(t<8*60){
m=t-8*60;
m1=m/60;
m2=m%60;
if(60-m2>=10)
printf("%d:%d",24-m1,60-m2);
else if(60-m2<10)
printf("%d:0%d",24-m1,60-m2);
}
return 0;
}
by cute_ @ 2024-10-14 19:21:44
#include<bits/stdc++.h>
using namespace std;
double s,v,m;
int n,a,t,b;
int main(){
cin>>s>>v;
n=8*60+24*60;
t=ceil(s/v)+10;
n=n-t;
if(n>=24*60) n-=24*60;
b=n%60;
a=n/60;
if(a<10){
if(b<10){
cout<<"0"<<a<<":0"<<b;
}
else{
cout<<"0"<<a<<":"<<b;
}
}
else{
if(b<10){
cout<<a<<":0"<<b;
}
else{
cout<<a<<":"<<b;
}
}
}
by kajews @ 2024-10-14 20:11:49
@cute_ 谢谢大佬,想问一下为什么要算24*60,能不能直接减
by _hellow @ 2024-10-15 20:33:24
@kajews 不可以的,因为是一天之内,也就可能在昨天下午开始出发,所以你的用24小时制
by kajews @ 2024-10-16 21:49:09
@_hellow 哦哦哦懂了,谢谢大佬