ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Задачи со всего света > задача:


160. 50388 - Number of Armstrong Numbers - 1

Гость
• Вопросы к жюри (1)

Задачи сборника

• 125. 50578 - Numrat Prim Mersenne
• 130. 50652 - Faktorizimi ne numra prim
• 132. 50474 - Sum of Two Primes
• 135. 50572 - Numrat Palindrome
• 140. 50393 - Palindromic Numbers
• 145. 50586 - Palindrome te thjeshta
• 148. 50412 - K numbers
• 150. 50375 - Area of Circles
• 160. 50388 - Number of Armstr...
• 160. 50571 - Numrat Armstrong
• 165. 50577 - Numrat perfekte dhe ...
• 190. 50533 - Contacts List
• 200. 50454 - What day is it?
• 210. 50369 - Base Conversion
• 250. 50385 - The 3n + 1 problem
• 260. 50493 - n-digit kth Prime Number

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Prepared by Ibrahim Mesecan.

Number of Armstrong Numbers

Number 153 has 3 digits and if you take the 3rd power of every digit and calculate the sum of them, you will have the same number again.
153 = 13 + 53 + 33
     = 1 + 125 + 27 = 153
Thus, for 1634 you should take the fourth powers of every digit (because the number has 4 digits) and calculate the sum. Because the sum is equal to the number itself, then, we say that this number is an Armstrong Number.

Question: Assume that you are given the following functions:

  • int numDigits (int num); // a function which calculates the number of digits in the given number (num)
  • int power(int n, int p); // calculates np
  • int getDigit(int num, int i);// gets ith digit of the given number num. And digits start from 1.

Using the functions above, in your program, calculate the number of Armstrong numbers between the given numbers n and m.

Input specification
There will be two numbers between 1 ≤ n < m ≤ 100000.
Note: For C and C++, you can include the functions using the following statement.
  #include "utils/armstrong.h" Download armstrong.h.

Output specification
show one integer: the number of Armstrong Numbers. If no Armstrong numbers exists, then show 0 (zero).

Input I   Input II  
 100 200  400 2000
Output 1   Output 2  
  1
  2

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

www.contester.ru