You are viewing a single comment's thread. Return to all comments →
here is my c# 100 ponits solution
using System; class Solution { static string Valid(int n, int k) { string s = ""; while (n > 0) { int r = n % k; n /= k; s += r.ToString(); } char[] charArray = s.ToCharArray(); Array.Reverse(charArray); return new string(charArray); } static void Main(string[] args) { string[] input = Console.ReadLine().Split(); int n = int.Parse(input[0]); int k = int.Parse(input[1]); int t = 0; for (int i = 1; i <= n; i++) { if (i.ToString() == new string(i.ToString().ToCharArray().Reverse().ToArray())) { if (Valid(i, k) == new string(Valid(i, k).ToCharArray().Reverse().ToArray())) { t += i; } } } Console.WriteLine(t); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #36: Double-base palindromes
You are viewing a single comment's thread. Return to all comments →
here is my c# 100 ponits solution