Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- namespace ExamPreparation
- {
- public sealed class Preparation
- {
- public static void Main()
- {
- string[] tokens = Console.ReadLine().Split();
- int baseN = int.Parse(tokens[0]);
- string number = tokens[1];
- string digits = "0123456789ABCDEF";
- int power = number.Length - 1;
- BigInteger sum = 0;
- for (int i = 0; i < number.Length; i++)
- {
- char currentDigit = number[i];
- int index = digits.IndexOf(currentDigit);
- BigInteger raisedPower = BigInteger.Pow(baseN, power);
- sum += index * raisedPower;
- power--;
- }
- Console.WriteLine(sum);
- }
- }
- }
Add Comment
Please, Sign In to add comment