求助!!有没有大佬帮忙看看哪错了,第十个测试点WA了
查看原帖
求助!!有没有大佬帮忙看看哪错了,第十个测试点WA了
1647447
JQTXZS2楼主2025/1/20 13:29
#include<iostream>
using namespace std;
int main() {
    int  distance, velocity,time;
    cin >> distance >> velocity;
    if (distance % velocity == 0) time = 10 + distance / velocity;
    else time = 11 + distance / velocity;
    string s = "08:00";
    int borrow1 ,borrow2,borrow3;
    while (time>0) {
        if (s[4] - '0' - 1 < 0) { borrow1 = 1; s[4] = (s[4] - '0' - 1+10) % 10 + '0';
        }
        else { borrow1 = 0; s[4] = (s[4] - '0' - 1) % 10 + '0'; }
        if (s[3] - '0' - borrow1 < 0) {
            borrow2 = 1;
                s[3] = (s[3] - '0' - borrow1 + 6) % 10 + '0';
        }
        else {
            borrow2 = 0; s[3] = (s[3] - '0' - borrow1) % 10 + '0';
        }
        if ((s[1] - '0' - borrow2)+(s[0]-'0')*10 < 0) {
            s[1] = ((s[1] - '0' - borrow2) + (s[0] - '0') * 10 + 24) % 10+'0';
            s[0]= ((s[1] - '0' - borrow2) + (s[0] - '0') * 10 + 24)/10 % 10+'0';
        }
        else {
            s[1] = ((s[1] - '0' - borrow2) + (s[0] - '0') * 10 ) % 10+'0';
            s[0] = ((s[1] - '0' - borrow2) + (s[0] - '0') * 10 ) / 10 % 10+'0';
        }
        time--;
    }
    cout << s;
                return 0;
}
2025/1/20 13:29
加载中...