题目:
题解:
class Solution {
public:int largestPalindrome(int n) {if (n == 1) {return 9;}int upper = pow(10, n) - 1;for (int left = upper;; --left) { // 枚举回文数的左半部分long p = left;for (int x = left; x > 0; x /= 10) {p = p * 10 + x % 10; // 翻转左半部分到其自身末尾,构造回文数 p}for (long x = upper; x * x >= p; --x) {if (p % x == 0) { // x 是 p 的因子return p % 1337;}}}}
};