20分,不知道错哪里,手搓样例全部通过

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

lyl__lxly @ 2024-07-09 10:46:22

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n%m!=0)
    {
        if(10+(n/m)+1>=60)
        {
            int g=10+(n/m)+1;
            if(g/60<10)
            {
                cout<<'0';
            }
            cout<<g/60<<':';
            if(g%60<10)
            {
                cout<<'0';
            }
            cout<<g%60;
        }
        else
        {
            cout<<"07:"<<60-(10+(n/m)+1);
        }
    }
    else
    {
        if(10+(n/m)>=60)
        {
            int g=10+(n/m);
            if(g/60<10)
            {
                cout<<'0';
            }
            cout<<g/60<<':';
            if(g%60<10)
            {
                cout<<'0';
            }
            cout<<g%60;
        }
        else
        {
            cout<<"07:"<<60-(10+(n/m));
        }
    }
}

by lyl__lxly @ 2024-07-09 10:46:44


by Hhy140516 @ 2024-07-09 11:12:08

#include<iostream>
using namespace std ;
int main()
{
    int w , h ;
    cin >> w >> h ;
    int ans = w / h ;
    if( w % h != 0 )
    {
        ans++ ;
    }
    ans += 10 ;
    int r = 1 ;
    while( ans >= 60 )
    {
        r++ ;
        ans -= 60 ;
    }
    if( r <= 8 )
    {
        cout << 0 << 8 - r << ":" ;
    }
    else
    {
        r -= 8 ;
        if( 24 - r < 10 )
        {
            cout << 0 ;
        }
        cout << 24 - r << ":" ;
    }
    if( 60 - ans < 10 )
    {
        cout << 0 ;
    }
    cout << 60 - ans ;
    return 0 ;
}

错了私信我


by Maisie586_ @ 2024-07-09 11:59:45

@lyl__lxly 代码贴上,求关

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

|