Operations Modulo m
Continuing their research on graphics cards, the team has not reached a point where they need several calculations per pair of numbers. The team is currently testing their code, so they ask you to write a program that would validate addition, subtraction, and multiplication of numbers modulo
Given two lists of integers
, you are asked to calculate:
As it’s faster to perform similar calculations on a GPU, you are asked to first print all the results for addition, then all the results for subtraction, and then all the results for multiplication.
The first line of the input contains two integers
n(1 ≤ n ≤ 100 000) and
m(1 ≤ m ≤ ).
The second line contains
( ≤ ≤ ).
The next line contains
( ≤ ≤ ).
The first line of the output should contain all the additions separated by a space
The second line should contain all the subtractions separated by a space
The final line should contain all the multiplications separated by a space
3 3 1 2 1 3 4 1
1 0 2 1 1 0 0 2 1
- Addition (the first line)
- Subtraction (the second line)
- Multiplication (the third line)
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 3 MB