70分求助

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

xiahaihan @ 2024-09-28 08:00:22

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int l;
    l=480;
    l-=10;
    l-=(a+b-1)/b;
    if(l/60<10)
    {
        if(l%60<10)cout<<0<<l/60<<":0"<<l%60;
        else cout<<0<<l/60<<':'<<l%60;
    }
    else
    {
        if(l%60<10)cout<<l/60<<":0"<<l%60;
        else cout<<l/60<<":"<<l%60;
    }
    return 0;
}

by _luogu_huowenshuo_ @ 2024-09-28 08:06:04

#include<bits/stdc++.h>
using namespace std;
int s,v,cnt,h,sum;
int main()
{
    cin >> s >> v;
    if(s%v==0) 
        cnt=s/v;
    else cnt=s/v+1;
    cnt+=10;
    if(cnt<=60)
    {
        if(60-cnt<10) 
            cout << "07:0" << 60-cnt;
        else 
            cout << "07:" << 60-cnt;
    }
    else
    {
        if(cnt%60==0) 
            h=cnt/60;
        else 
            h=cnt/60+1;
        if((8-h)<0)
        {
            if(h%8==0) 
                sum=h/8;
            else 
                sum=h/8+1;
            if(60-cnt%60==60) 
                cout << ((8+sum*24)-h)%24+1 << ":00";
            else
            {
                if(60-(cnt%60)<10) 
                    cout << ((8+sum*24)-h)%24 << ":0" << 60-(cnt%60);
                else 
                    cout << ((8+sum*24)-h)%24 << ":"<<60-(cnt%60);
            }
        }
        else
        {
            if(60-(cnt%60)<10) 
                cout << "0" << 8-h << ":0" << 60-(cnt%60);
            else 
                cout << "0" << 8-h << ":" << 60-(cnt%60);
        }
    }
    return 0;
}

@xiahaihan


by xiahaihan @ 2024-09-28 08:39:50

@_luoguhuowenshuo 谢谢,已关


|