50分求调

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

zyyzyy100 @ 2024-07-23 20:58:06

#include<bits/stdc++.h>
using namespace std;
int s,v;
int t;
int t1=7,t2=50;
int main()
{
    cin>>s>>v;
    if(s%v!=0)  t=s/v+1;
    else t=s/v;
    t2-=t;
    if(t2>=0)
    {
        if(t1>=10)cout<<t1<<':'<<t2;
        else cout<<"0"<<t1<<':'<<t2;
    }
    else
    {
        while(t2<0) 
        {
            t1--;
            t2+=60;
        }
        if(t1<=10) cout<<"0"<<t1<<':'<<t2;
        else cout<<t1<<':'<<t2;
    }
}

by jiangyichen_10 @ 2024-07-26 21:32:30

AC了

求关
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s, v, h = 8, m = 60, ht, mt;
    cin >> s >> v;
    if (s % v == 0) {
        mt = s / v + 10;
    } else {
        mt = s / v + 11;
    }
    ht = mt / 60;
    mt %= 60;
    if (mt == 0) {
        m = 0;
    } else {
        h--;
        m -= mt;
    }
    if (ht >= 8) {
        h += 24;
    }
    h = h - ht;
    printf("%.2d", h);
    cout << ":";
    printf("%.2d", m);
    return 0;
}

|