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

Турниры > IMPC - 2013-2014 > задача:


2013-04-40. 50338 - Convert Into Decimal

IMPC - 2013-2014

Старт: 16.мар.2013 в 12:00:00
Финиш: 16.мар.2013 в 17:00:00
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• 14-07-50. 50367 - Bar Codes
• 2013-03-10. 50579 - Numrat pentag...
• 2013-03-20. 50589 - Numri i vezeve...
• 2013-03-30. 50559 - Faktoret e thje...
• 2013-03-40. 50685 - Perdorimi i dh...
• 2013-04-10. 50335 - Five Math Ope...
• 2013-04-100. 50323 - Filtering Cont...
• 2013-04-30. 50337 - Exam Averages
• 2013-04-40. 50338 - Convert In...
• 2013-04-50. 50774 - Hot Potato
• 2013-04-70. 50296 - Total Discount...
• 2013-04-80. 50343 - The number of...
• 2013-04-90. 50332 - Variance of a ...
• 2013-05-10. 50552 - Kepuce te perd...
• 2013-05-30. 50580 - Sa dite kane ka...
• 2013-05-40. 50553 - I pjestueshem...
• 2013-05-50. 50593 - Transportimi

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

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

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

Convert Into Decimal

We use positional number system. In this system, the rightmost digit has the lowest place value (1), and each successive position to the left has a higher place value with respect to its base. That is every digit makes a value according to its position. In the number (345)10, because 3 is in the "hundreds" position, it's multiplied 100, such that the number (345)10 = (3*100) + (4*10) + (5*1).

Frequently, we need to use numbers in different bases. And, we convert them in to decimal system. Write a program that is going to read a number in a different base and then the program is going to convert the given number into decimal system.

A number can be converted in to decimal by multiplying the digits with their respective positional base powers and then summing up.
For example: (1202)3 = (2x30 + 0x31 +2x32 +1x33) = (2+0+18+27) = (47)10

Input specification
First, you will be given two numbers: the lenght of the number (n) and the base where 1 ≤ n ≤ 32 and 2 ≤ base < 10. Then, the following line will contain an n-digit number. Each digit in the following line is between 0 and (base-1). The most significant digit of the number is on the left most side.
Note: Please pay attention that the number can be upto 32 digits long. Thus you can read it digit by digit.

Output specification
Show one integer number that represents the decimal equivalent of the given number. Note that the integer result is always within the unsigned int range (between 0 and 4,294,967,295).

 Sample Input I   Sample Input II 
  3 4
  123
  7 8
  1234567   
 Sample Output I   Sample Output II 
  27   342391  

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

www.contester.ru