HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


155. 50379 - a^b modulus k

Guest
• Review clarifications (2)

Volume problems

• 132. 50504 - School contest
• 136. 50443 - Dajte Express
• 147. 50553 - Divisible by m
• 148. 50596 - Your Ride Is Here (US...
• 148. 50596 - Your Ride Is Here (US...
• 150. 50763 - Valid Password
• 151. 50560 - Max Distance
• 153. 50368 - Right-most non zero d...
• 155. 50379 - a^b modulus k
• 158. 50404 - Sum of Self Powers
• 30. 50764 - Fast Typing Competition
• 50303 - Pattern
• 50882 - FizzBuzz
• 50308 - IT Knowledge Seminars
• 50320 - Random Sorted List
• 001. 50385 - From m to n
• 002. 50365 - Sum of the numbers f...

Feedback

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

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

a^b modulus k

Question:
Write a program that calculates bth power of a modulus k. For example, if you are asked to calculate 2^6 mod 7; 6th power of 2 is 64 thus 64 modulus 7 is 1.

Input specification
You will be given 3 integers, a, b, and k where b represents the power and k represents the modulus operand and 0 ≤ b ≤ 1000 and 1 < (a and k) ≤ 1000.

Output specification
Show just one integer number which is between 0 and k-1.

Sample Input I   
  2 6 5
Sample Input II   
  3 6 11
Sample Output I   
  4
Sample Output II   
  3


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

www.contester.ru