Luo Gu -P1424 small fish swimming time

Luo Gu -P1424 small fish swimming time

Link to the original question: https://www.luogu.com.cn/problem/P1425


Title Description

London Olympics to come, small fish swimming in a desperate exercise preparing for the swimming competition, the poor fish does not know the fish is unable to participate in the Olympic Games of mankind.

On this day, small fish to their swimming time to do accurate timing (timing in this problem are in 24-hour calculation), it finds d minutes and themselves when a from b points has been swimming to the day of c, would you please help small fish calculate that this day tour altogether how much time?

The fish swim very hard for it, you can not be wrong, oh.

Input Format

Input line 4 integer, each represent a, b, c, d.

Output Format

One line output two integers e and f, are separated by spaces, which in turn represents the fish swim many hours day total number of minutes. Wherein f represents an integer of minutes should be less than 60.

Sample input and output

Input # 1

12 50 19 10

Output # 1

6 20

Description / Tips

For all the test data, 0≤a, c≤24,0≤b, d≤60, and the end time must be later than the start time.

C ++ code

#include <iostream>
using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b<=d)
            cout<<c-a<<' '<<d-b<<endl;
    else
            cout<<c-a-1<<' '<<d+60-b<<endl;
    return 0;
}

Guess you like

Origin www.cnblogs.com/yuzec/p/12467652.html