ydwide @ 2024-12-04 21:17:31
#include<stdio.h>
int main(){
int s,v;
scanf("%d%d",&s,&v);
int m;
if(s%v==0){
m=(int)(s/v)+10;
}else{
m=(int)(s/v)+1+10;
}
int h;
if(m>8*60){
if(m%60==0){
h=(m-480)/60;
}else{
h=(m-480)/60+1;
}
printf("%d:%d",24-h,60-m);
}else{
if(m%60==0){
h=m/60;
}else{
h=m/60+1;
}
printf("0%d:%d",8-h,60-m);
}
return 0;
}
by pjh0625 @ 2024-12-04 21:27:40
@ydwide
#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;//ceil()
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;
}
return 0;
}
by lipeizheng @ 2024-12-04 21:50:54
太复杂了,其实把时间用分钟表示,然后用double 定义 t 和 s 求出用时(注意向上取整)在与时间相减,若用时大于470分钟,再把时间加上24*60,之后补0输出即可。 AC记录https://www.luogu.com.cn/record/192845786
by woshilaohu @ 2024-12-08 22:47:39
@[pjh0625](luogu://user/1339889@pjh0625逆天哥们要的就是c你发个c++
by pjh0625 @ 2024-12-08 22:58:57
@woshilaohu
#include <stdio.h>
#include <math.h>
int main() {
double s, v;
int n, a, t, b;
scanf("%lf %lf", &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) {
printf("0%d:0%d\n", a, b);
} else {
printf("0%d:%d\n", a, b);
}
} else {
if (b < 10) {
printf("%d:0%d\n", a, b);
} else {
printf("%d:%d\n", a, b);
}
}
return 0;
}