-
Notifications
You must be signed in to change notification settings - Fork 0
/
FullScore.cs
31 lines (23 loc) · 886 Bytes
/
FullScore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
List<int> reliablePossiblePalindromes = new List<int>();
for (int left = 100; left < 1000; ++left)
{
if (left % 11 == 0)
for (int right = 100; right < 1000; right++)
reliablePossiblePalindromes.Add(left * right);
}
int t = Convert.ToInt32(Console.ReadLine());
for (int a0 = 0; a0 < t; a0++)
{
int n = Convert.ToInt32(Console.ReadLine());
int largestPalindrome = 0;
foreach (int possiblePalindrome in reliablePossiblePalindromes)
if (isNumberAPalindrome(possiblePalindrome.ToString(), n) && possiblePalindrome > largestPalindrome)
largestPalindrome = possiblePalindrome;
Console.WriteLine(largestPalindrome);
}
bool isNumberAPalindrome(string num, int MaxValue)
{
if (num.Length == 6 && num[0] == num[5] && num[1] == num[4] && num[2] == num[3] && int.Parse(num) < MaxValue)
return true;
return false;
}