#K61932. Cutting Rope Problem
Cutting Rope Problem
Cutting Rope Problem
Given a rope of length \(N\) and an integer \(L\) representing the minimum allowed length for each piece, determine if it is possible to cut the rope into pieces such that every piece is at least \(L\) units long and the rope is completely divided into equal parts. More formally, output 1
if \(N \ge L\) and \(N\) is divisible by \(L\) (i.e. \(N \bmod L = 0\)); otherwise, output 0
. Note that if \(N < L\), no valid cutting is possible, and the answer is 0
.
For example:
- For \(N = 10\) and \(L = 2\): Since \(10 \bmod 2 = 0\), the output is
1
. - For \(N = 10\) and \(L = 1\): Since \(10 \bmod 1 = 0\), the output is
1
. - For \(N = 1\) and \(L = 2\): Since \(1 < 2\), the output is
0
.
inputFormat
The input consists of a single line containing two space-separated integers \(N\) (the length of the rope) and \(L\) (the minimum allowed length of each piece).
outputFormat
Output a single integer: 1
if the rope can be cut into pieces of equal length with each piece having length at least \(L\) (i.e. if \(N \geq L\) and \(N \bmod L = 0\)), otherwise output 0
.
10 2
1