说句闲话:我这代码怎么看怎么不对,但就是能过

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

abstractROMANCE @ 2024-10-04 16:33:02


#include<bits/stdc++.h>
using namespace std;
int s,v,t;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>s>>v;
    t=(s+v-1)/v+10;
    int tmp=86400-t;//注意看这里
    int ans_hour=(8+tmp/60)%24;
    int ans_min=tmp%60;
    if(ans_hour<10) cout<<"0";
    cout<<ans_hour<<":";
    if(ans_min<10) cout<<"0";
    cout<<ans_min<<endl;
    return 0;
}

by Terrible @ 2024-10-04 16:57:13

$$\begin{aligned}&\left(8+\left\lfloor\dfrac{86400-t}{60}\right\rfloor\right)\bmod 24\\=&\left(1424+\left\lfloor\dfrac{1440-t}{60}\right\rfloor\right)\bmod 24\\=&\left(8+\left\lfloor\dfrac{1440-t}{60}\right\rfloor\right)\bmod 24\end{aligned}$$ 详见[同余](https://oi-wiki.org/math/number-theory/basic/#%E5%90%8C%E4%BD%99)。

|