__youzimo2014__ @ 2023-08-28 11:22:09
//
// main.cpp
// 上学迟到
//
// Created by 游子墨 on 2023/5/29.
//
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
// insert code here...
unsigned s, u;
scanf("%d %d", &s, &u);
double WalkingTime = ceil(1.0 * s / u) + 10.0;
double setOutTime = 480 - WalkingTime;
unsigned short hours = setOutTime / 60;
unsigned short min = setOutTime - (hours * 60);
printf("%02d:%02d", hours, min);
return 0;
}
by __youzimo2014__ @ 2023-08-28 11:24:24
对了,最后把s, u改成double, 然后吧%d 改成了%lf还是70分
by zhaojianchao @ 2023-08-28 12:04:09
@youzimo 你参考一下
#include<bits/stdc++.h>
#define int long long
using namespace std;
double s,v;
int h=8,m=0;
signed main(){
cin>>s>>v;
int t=ceil(s/v*1.0)+10;
int a=t/60,b=t%60;
if(b!=0) h--,m=60-b;
if(a>h) a-=h,h=24-a;
else h-=a;
cout<<h/10<<h%10<<':'<<m/10<<m%10;
return 0;
}