Z1660402068 @ 2024-01-28 19:26:35
#include <stdio.h>
int main ()
{
int n,m,v,s,x,f;
scanf("%d%d",&s,&v);
n=s/v+1+10;
if(n<=480)
{
x=n/60;
f= 60-(n-x*60);
if(f==60)
f=0;
x=7-x;
printf("%02d:%02d",x,f);
}
else
{
int m=n-480;
x=m/60;
f=60-(n-x*60);
x=23-x;
if(f==60)
f=0;
printf("%02d:%02d",x,f);
}
return 0;
}
by 1612855242ytq @ 2024-01-28 19:50:35
如果路程除以速度正好能整除,那n=s/v+1+10;这里还需要加一吗
但这个可能没什么大问题,主要问题是如果n能被60整除呢,比如说你看看n=60,你输出的是多少
by GaoFeng123 @ 2024-01-28 19:54:50
@Z1660402068
测一下100 100 就过不了了
问题应该在地6行。
by Z1660402068 @ 2024-01-28 19:59:39
@GaoFeng123 @1612855242ytq 6:60,确实不对,谢谢
by Z1660402068 @ 2024-01-28 20:06:23
@GaoFeng123 确实,里面的n<=480后面对于n=60的整倍数就不对了,谢谢
by Z1660402068 @ 2024-01-28 20:22:42
@Z1660402068 终于改好了
#include <stdio.h>
int main ()
{
int n,m,v,s,x,f;
scanf("%d%d",&s,&v);
if(s%v!=0)
n=s/v+1+10;
else n=s/v+10;
if(n<=480)
{
if(n%60==0)
{
x=n/60;
f=0;
x=8-x;
}
else
{
x=n/60;
f= 60-(n-x*60);
x=7-x;
}
printf("%02d:%02d",x,f);
}
else
{
int m=n-480;
if(m%60==0)
{
x=n/60-8;
f=0;
x=24-x;
}
else
{
x=n/60-8;
f= 60-(n-480-x*60);
x=23-x;
}
printf("%02d:%02d",x,f);
}
return 0;
}