#P4157. [SCOI2006] 整数划分

    ID: 3090 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>高精度2006四川各省省选枚举,暴力快速傅里叶变换 FFT

[SCOI2006] 整数划分

Description

Read a positive integer nn from the file (10n3100010 \le n \le 31000). You need to write nn as a sum of several positive integers, and make the product of these integers as large as possible.

For example, when n=13n=13, if nn is written as 4+3+3+34+3+3+3 (or 2+2+3+3+32+2+3+3+3), the product =108=108 is maximal.

Input Format

One line with a positive integer nn.

Output Format

Line 1: output an integer, the number of digits of the maximum product.

Line 2: output the first 100 digits of the maximum product. If it has fewer than 100 digits, output the maximum product with its actual number of digits.

13
3
108

Hint

Constraints

For all testdata, 10n3100010 \le n \le 31000, and it is guaranteed that the number of digits of the maximum product does not exceed 5000 digits.

Translated by ChatGPT 5