#P1207. [USACO1.2] 双重回文数 Dual Palindromes

[USACO1.2] 双重回文数 Dual Palindromes

Description

Given two decimal integers n,sn, s, find the first nn decimal numbers greater than ss that are palindromic in at least two bases among base 22 through base 1010, and output them.

A solution to this problem does not need integers wider than 3232 bits.

Input Format

One line containing two positive integers n,sn, s separated by a space.

Output Format

Output nn lines. Each line contains one number that satisfies the requirement, in ascending order.

3 25

26
27
28

Hint

Constraints
For 100%100\% of the testdata, 1n151 \le n \le 15, 1s99991 \le s \le 9999.

Problem translation from NOCOW.

USACO Training Section 1.2.

Translated by ChatGPT 5