我在本地里可以运行,提交上去结果全是红的,我感觉思路问题。

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

lvjie14 @ 2024-10-03 22:02:44

#include <bits/stdc++.h>

using namespace std;

int s,v;
int main(){
    scanf("%d%d%", &s, &v);
    int minutes = (s+v-1)/v + 10;
    cout<<minutes<<endl;
    int HH = (8-(minutes+60-1)/60)>=0 ? (8-(minutes+60-1)/60) : 24+(8-(minutes+60-1)/60);
    int MM = 60-minutes%60;
    printf("%02d:%02d",HH,MM);
    return 0;
}

by Lisuyang @ 2024-10-03 22:26:56

@lvjie14

#include <bits/stdc++.h>
using namespace std;
int s, v, t;
int main(){
    scanf("%d%d", &s, &v);
    t = 480 - (s + v - 1) / v - 10;
    if(t < 0) t += 1440;
    printf("%02d:%02d", t / 60, t % 60);
    return 0;
}

by Lisuyang @ 2024-10-03 22:29:41

另外,这怎么多了个%?

scanf("%d%d%", &s, &v);

by Lisuyang @ 2024-10-03 22:30:50

你的WA绝对是格式化输入的锅


by Lisuyang @ 2024-10-03 22:32:28

还有:用于调试的代码为何不注释


by lvjie14 @ 2024-10-04 15:49:23

@Lisuyang 大意了,提交答案的时候忘了删掉。


|