Quotient and Remainder
Programming Basics · C++
TASK
Problem
In “Quotient and Remainder”, input integer data and print integer quotient and remainder of a divided by positive b.
EXAMPLE
Example
10 3
3 1
LIMITS
Constraints
0 ≤ values ≤ 10^12; every divisor/capacity is positive.
LEARN
Theory for this problem
+
For non-negative integers, `/` gives the integer quotient and `%` gives the remainder.
Connection to “Quotient and Remainder”: 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 “Quotient and Remainder”, 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 a, b;
cin >> a >> b;
cout << a / b << ' ' << a % b << '\n';
return 0;
}