求助,第七个测试点过不了

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

silver_eagle @ 2024-08-18 16:33:54

#include<stdio.h>
int x,v,minite,hour,t_hour;
int main(void)
{
    scanf("%d %d",&x,&v);
    minite=x/v+10;
    hour=minite/60;
    for(t_hour=31-hour;t_hour>24;t_hour-=24)
    {;}
    minite%=60;
    if (x%v!=0)
        minite++;
    minite=60-minite;
    printf("%02d:%02d",t_hour,minite);
    return 0;
}

by AI9527 @ 2024-08-18 16:36:44

@silver_eagle 我的AC代码


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long double s,v;
    long int s2=470;
    cin>>s>>v;
    s=s/v;
    int d=s;
    if(s>d)
    {
        d+=1;
    }
    s2-=d;
    int h=s2/60;
    int m=s2-h*60;
    if(h>=0&&m>=0)
    {
        if(h<10)
    {
        cout<<'0'<<h;
    }
    else
    {
        cout<<h;
    }
    cout<<':';
    if(m<10)
    {
        cout<<'0'<<m;
    }
    else
    {
        cout<<m;
    }
    }
    else
    {                                   
        if(m==0)
        {
            h=24+h;

        }
        else
        {
            h=23+h;
            m=60+m;
        }
            if(h<10)
    {
        cout<<'0'<<h;
    }
    else
    {
        cout<<h;
    }
    cout<<':';
    if(m<10)
    {
        cout<<'0'<<m;
    }
    else
    {
        cout<<m;
    }
    }
}

by Emil_ @ 2024-08-18 16:38:06

@silver_eagle ac代码:

#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=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 silver_eagle @ 2024-08-18 20:22:33

@Emil_ 感谢QAQ


by silver_eagle @ 2024-08-18 20:22:53

@AI9527 感谢


by Stars_Shine @ 2024-08-19 14:11:29

本蒟蒻的有点长,给你看看

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a,b;
    cin>>a>>b;
    int h=0,m=0;
    int time=a/b+10,lass=0,lass2=0;
    if(a%b!=0){
        time++;
    }
    if(time>480){
        lass=time-480;
        lass2=24*60-lass;
        h=floor(lass2/60);
        if(h<10){
            cout<<"0"<<h<<":";
        }
        else{
            cout<<h<<":";
        }
        m=lass2-60*h;
        if(m<10){
            cout<<"0"<<m;
        }
        else{
            cout<<m;
        }
    }
    else{
        lass=480-time;
        h=floor(lass/60);
        if(h<10){
            cout<<"0"<<h<<":";
        }
        else{
            cout<<h<<":";
        }
        m=lass-60*h;
        if(m<10){
            cout<<"0"<<m;
        }
        else{
            cout<<m;
        }
//      cout<<h<<":"<<m;
    }
    return 0;
}

|