70分WA求看QAQ

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

二流公民 @ 2024-10-17 10:40:21

#include<bits/stdc++.h>
using namespace std;
int minn;//最后一版orz 
double s,v;
int main(){
    cin>>s>>v;
    minn=ceil(s/v)+10;
    //cout<<minn<<endl;
    int hour,num;
    while(minn>=60){
        minn=minn-60;
        num++;
    }//num存小时数,minn存剩余分钟数 
    if(minn==0&&num<=8){
        cout<<"0"<<8-num<<":"<<"00";
        return 0;
    }//今天出发且整点 
    if(num<8){
        if(minn>=51){
            cout<<"0"<<8-num-1<<":0"<<60-minn;
            return 0;
        }
        else{
            cout<<"0"<<8-num-1<<":"<<60-minn;
            return 0;
        }
    }//今天出发不整点 
    if(num>=8&&num<=22){
        if(minn==0){
            cout<<24-(num-8)<<":"<<"00";
            return 0;
        }
    }//提前出发,小时数为二位,整点 
    if(num>=8&&num<22){
        if(minn>=51){
            cout<<24-(num-8)-1<<":"<<"0"<<60-minn;
            return 0;
        }
        else{
            cout<<24-(num-8)-1<<":"<<60-minn;
            return 0;
        }
    }//提前出发,小时数为二位,不整点 
    if(num>22){
        if(minn==0){
            cout<<"0"<<24-(num-8)<<":"<<"00";
            return 0;
        }
    }//提前出发,小时数为个位,整点
    if(num>=22){
        if(minn>=51){
            cout<<"0"<<24-(num-8)-1<<":"<<"0"<<60-minn;
            return 0;
        }
        else{
            cout<<"0"<<24-(num-8)-1<<":"<<60-minn;
            return 0;
        }
    }//提前出发,小时数为个位,整点
    return 0;
}

注释在代码里面 前三个点WA 求大佬看看吧。。。孩子调了一个小时了。。。


by Yi_Mo @ 2024-10-19 08:41:53

@二流公民

#include<bits/stdc++.h>
using namespace std;
int minn;//最后一版orz 
double s,v;
int main(){
    cin>>s>>v;
    minn=ceil(s/v)+10;
    //cout<<minn<<endl;
    int hour,num = 0;

    //初始化 初始化 初始化

    while(minn>=60){
        minn=minn-60;
        num++;
    }//num存小时数,minn存剩余分钟数 
    if(minn==0&&num<=8){
        cout<<"0"<<8-num<<":"<<"00";
        return 0;
    }//今天出发且整点 
    if(num<8){
        if(minn>=51){
            cout<<"0"<<8-num-1<<":0"<<60-minn;
            return 0;
        }
        else{
            cout<<"0"<<8-num-1<<":"<<60-minn;
            return 0;
        }
    }//今天出发不整点 
    if(num>=8&&num<=22){
        if(minn==0){
            cout<<24-(num-8)<<":"<<"00";
            return 0;
        }
    }//提前出发,小时数为二位,整点 
    if(num>=8&&num<22){
        if(minn>=51){
            cout<<24-(num-8)-1<<":"<<"0"<<60-minn;
            return 0;
        }
        else{
            cout<<24-(num-8)-1<<":"<<60-minn;
            return 0;
        }
    }//提前出发,小时数为二位,不整点 
    if(num>22){
        if(minn==0){
            cout<<"0"<<24-(num-8)<<":"<<"00";
            return 0;
        }
    }//提前出发,小时数为个位,整点
    if(num>=22){
        if(minn>=51){
            cout<<"0"<<24-(num-8)-1<<":"<<"0"<<60-minn;
            return 0;
        }
        else{
            cout<<"0"<<24-(num-8)-1<<":"<<60-minn;
            return 0;
        }
    }//提前出发,小时数为个位,整点
    return 0;
}

|