C. Wet Shark and Flowers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharksi andi + 1 are neighbours for alli from1 to n - 1. Sharksn and 1 are neighbours too.
Each shark will grow some number of flowers si. Fori-th shark valuesi is random integer equiprobably chosen in range fromli tori. Wet Shark has it's favourite prime numberp, and he really likes it! If for any pair ofneighbouring sharksi and j the product