DMOPC '21 Contest 4 P3 - Palindromic Presents

View as PDF

Submit solution

Points: 12 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type

Petep is preparing a Christmas present for Reter! As they both love palindromes, Petep decides to gift Reter a set of 10 distinct non-negative palindromic integers. To make the best possible present, Petep decides that the sum of any subset of these integers (including the sum of all 10 integers) should also be a palindrome, and the sum of the 10 integers should be as small as possible to ensure that they fit under the Christmas tree. Please help Petep find any set of 10 integers satisfying these properties.

Input Specification

There is no input for this problem.

Output Specification

Output 10 non-negative integers each on its own line, the set of integers in Petep's present.


If your output is improperly formatted, the sum of all 10 integers exceeds 10^{18}, the 10 integers are not all distinct, or the sum of any subset of the integers is not a palindrome, you will receive 0 points.

Otherwise, let S be the sum of the 10 integers in your solution, and let S' be the sum of the 10 integers in the best possible solution.

If S = S', you will receive full points. Otherwise, you will receive a positive number of points based on how close S is to S'. It is guaranteed that a solution with a larger S will not score more points than a solution with a smaller S.

Sample Output



This output is only provided to clarify the output format. Note that it would score 0 points because, for example, 2 + 7 + 828 = 837 is not a palindrome.


There are no comments at the moment.