Minutes to Hours
Programming Basics · C++
TASK
Problem
In “Minutes to Hours”, input integer data and convert total minutes to full hours and remaining minutes.
EXAMPLE
Example
59
0 59
LIMITS
Constraints
0 ≤ n ≤ 10^12.
LEARN
Theory for this problem
+
For non-negative integers, `/` gives the integer quotient and `%` gives the remainder.
Connection to “Minutes to Hours”: here, integer `/` and `%` provide the quotient and remainder, which is useful for digit extraction and cyclic arithmetic.
NEED HELP?
Hints
+
['Choose division and remainder operations that match the requested decomposition.', 'After solving “Minutes to Hours”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']
ANSWER
Solution
+
#include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
cout << n / 60 << ' ' << n % 60 << '\n';
return 0;
}