P5707 70分求助

P5707 【深基2.例12】上学迟到

NewMinecraft @ 2024-08-18 11:48:42

#include <bits/stdc++.h>

using namespace std;

int main(){

    double s, v;
    cin >> s >> v;
    int n = ceil(s / v);
    int ans = 470 - n;
    int HH = ans / 60, MM = ans % 60;
    if(HH < 10){
        cout << 0;
    }
    cout << HH << ":";
    if(MM < 10){
        cout << 0;
    }
    cout << MM;

    return 0;
}

by dongzirui0817 @ 2024-08-18 11:53:44

@NewMinecraft 由于数据的离谱性,yyy有可能昨天开始赶路。


by jiangmuhangpphooga @ 2024-08-18 11:54:26

@NewMinecraft 万一是要在上一天出发才不能迟到呢?


by jiangmuhangpphooga @ 2024-08-18 11:57:46

@NewMinecraft

可以这样判断yyy昨天赶路

time=ceil(1.0*s/v)+10;
    x=480-time;
    if(x<0){
        //自己写       
  }
.............

by jzm_2024 @ 2024-08-18 12:16:02

#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;
    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;
}

以A求关


by NewMinecraft @ 2024-08-19 11:36:34

谢谢各位回答


by jiangmuhangpphooga @ 2024-08-19 11:41:24

@NewMinecraft ac了吗?


|