Reparto de manzanas - 2#4717

Reparto de manzanas - 2 (Editorial)

Algorithm Analysis

To solve the problem, it is sufficient to find the remainder of dividing k by n.

Algorithm Implementation

Read the input data. Calculate and output the answer.

scanf("%d %d",&n,&k);
printf("%d\n",k % n);

Java Implementation

import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner con = new Scanner(System.in);
        int n = con.nextInt();
        int k = con.nextInt();
        System.out.println(k % n);
    }
}