HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50256 - Sequence

Guest
• Discussion of problem (1)

Section problems

• 50949 - Vowel or Consonant
• 50881 - Exchange the Values
• 51114 - The traveling vehicle
• 50937 - Calculate the Average
• 50947 - Calculate the Average
• 50964 - Increasing or Decreasing
• 50948 - Translate Score into Grade
• 50280 - Division
• 50256 - Sequence
• 50257 - Galls village
• 50266 - Kovrov
• 50254 - Lawyers Council
• 50260 - What about judges?
• 50259 - Many-coloured roads
• 50278 - ATM
• 50277 - Unusual Lottery
• 50283 - Tetris 3D

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 3000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Кирилл Бутин, ПГУ.

You are given an infinite sequence of integers:
A0 = 0
Ai = ( Ai-1 + q ) mod p, for i > 0

Where p is a prime number, a mod p is reminder of division a by p.

Your task is to count how many integers in the range [0..p-1] are not included in this sequence. Notice that p can be very large.

Input
The first line contains one prime integer p.
The second line contains one integer q. (0 ≤ qp ≤ 10100).

Output
Output a single number – the answer for the problem.

Input 1 Output 1
5
1
0

Для отправки решений необходимо выполнить вход.

www.contester.ru