lan_go @ 2024-11-18 22:52:42
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int M=5050;
signed main ()
{
int u,s;
cin>>s>>u;
int sj;
sj=ceil(s/u)+10;
int xiaoshi=8,fenzhong=0;
fenzhong-=sj;
while(fenzhong<0){
fenzhong+=60;
xiaoshi-=1;
}
if(xiaoshi<10){
cout<<0<<xiaoshi<<':';
}else cout<<xiaoshi<<':';
if(fenzhong<10){
cout<<0<<fenzhong-1;
}else cout<<fenzhong-1;
return 0;
}
by 南苑 @ 2024-11-18 23:36:00
@lan_go
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int M=5050;
signed main ()
{
int u,s;
cin>>s>>u;
int sj;
sj=ceil((s / 1.0) / u + 10);
int xiaoshi=8,fenzhong=0;
fenzhong-=sj;
while(fenzhong<0){
fenzhong+=60;
xiaoshi-=1;
}
if(xiaoshi<0)xiaoshi+=24;
if(xiaoshi<10){
cout<<0<<xiaoshi<<':';
}else cout<<xiaoshi<<':';
if(fenzhong<10){
cout<<0<<fenzhong;
}else cout<<fenzhong;
return 0;
}
一个问题是你while循环后xiaoshi<0的情况没考虑,一个是最后输出的时候,fenzhong-1会被一个测试点卡掉,用sj=ceil((s / 1.0) / u + 10);即可解决。
by lan_go @ 2024-11-19 22:00:08
感谢