Baekjoon Algorithm | Problem 10430: Remainder

Source

https://www.acmicpc.net/problem/10430

Problem

Solve Baekjoon Online Judge problem 10430, Remainder.

Input

Follow the input format and constraints given in the original problem statement.

Output

Print the answer required by the problem.

Sample Input 1

5 8 4

Sample Output 1

1 1 0 0

Solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            StringTokenizer input = new StringTokenizer(br.readLine(), " ");
            int a = Integer.parseInt(input.nextToken());
            int b = Integer.parseInt(input.nextToken());
            int c = Integer.parseInt(input.nextToken());

            System.out.println((a + b) % c);
            System.out.println(((a % c) + (b % c)) % c);
            System.out.println((a * b) % c);
            System.out.println(((a % c) * (b % c)) % c);
        }
    }
}