QianMengxun @ 2023-10-17 20:04:24
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int c(double x)
{
if (x == int(x)) return x;
else return x+1;
}
int main()
{
double s,v;
cin >> s >> v;
int t = c(s/v*1.0)+10; //向上取整+倒垃圾
int x = 8,y = 0;
y -= t;
while (y < 0)
{
x--; //借位
y+=60;
}
printf("%02d:%02d",x,y);
return 0;
}
by C_Rong @ 2023-10-17 20:11:20
#include<bits/stdc++.h>
using namespace std;
int s,v;
bool flag;
int ans;
int ans_h;
int ans_min;
int main(){
cin>>s>>v;
if(s / v + 10 > 480)flag = true;
if(!flag){
if(s % v == 0)ans = 480 - s / v - 10;
else ans = 480 - s / v - 10 - 1;
int tmp = ans;
while(1){
if(tmp < 60)break;
tmp -= 60,ans_h ++;
}
ans_min = tmp;
if(ans_h < 10 && ans_min < 10)cout<<0<<ans_h<<":"<<0<<ans_min;
if(ans_h < 10 && ans_min >= 10)cout<<0<<ans_h<<":"<<ans_min;
if(ans_h >= 10 && ans_min < 10)cout<<ans_h<<":0"<<ans_min;
if(ans_h >= 10 && ans_min >= 10)cout<<ans_h<<":"<<ans_min;
exit(0);
}
else {
if(s % v == 0)ans = s / v + 10;
else ans = s / v + 10 + 1;
int tmp = ans;
tmp -= 480;
ans_h = 23;
ans_min = 60;
while(1){
if(tmp < 60)break;
tmp -= 60,ans_h --;
}
ans_min = 60 - tmp;
if(ans_h < 10 && ans_min < 10)cout<<0<<ans_h<<":"<<0<<ans_min;
if(ans_h < 10 && ans_min >= 10)cout<<0<<ans_h<<":"<<ans_min;
if(ans_h >= 10 && ans_min < 10)cout<<ans_h<<":0"<<ans_min;
if(ans_h >= 10 && ans_min >= 10)cout<<ans_h<<":"<<ans_min;
exit(0);
}
}
可以这样写
by chenxizhe2 @ 2023-10-17 20:16:22
这是一道偏向数学思维的题,所以
我们可以打表。
by chenxizhe2 @ 2023-10-17 20:19:09
题解可以看看,我推荐第5和第6个,很清晰明了.
by chenxizhe2 @ 2023-10-17 20:20:19
@chenxinrong 您这个复制题解也得复制一个别人看得懂的吧.
by QianMengxun @ 2023-10-17 20:21:57
@chenxizhe2 谢谢!
by QianMengxun @ 2023-10-17 20:22:46
@chenxinrong 谢谢
by chenxizhe2 @ 2023-10-17 20:30:32
@QianMengxun 没事