#P15802. [GESP202603 七级] 拆分

    ID: 17865 远端评测题 1000ms 512MiB 尝试: 17 已通过: 2 显示难度普及 上传者: 标签>动态规划 DP数学贪心2026分类讨论GESP

[GESP202603 七级] 拆分

Background

Related multiple-choice and true/false problems: https://ti.luogu.com.cn/problemset/1211.

Problem Description

Xiao A wants to split a positive integer nn into the sum of several positive integers, and maximize the product of the integers after splitting. Xiao A hopes you can help him compute the maximum possible product. Since the answer may be very large, you only need to output the result modulo 10910^9.

Formally, a split of nn is a set of positive integers a1,,aka_1,\dots,a_k such that a1++ak=na_1+\cdots+a_k=n, where 1kn1\leq k\leq n. You need to output, among all splits of nn, the maximum value of a1××aka_1\times \cdots\times a_k modulo 10910^9.

Input Format

The first line contains a positive integer tt, the number of test cases.

For each test case: one line containing an integer nn, the given positive integer.

Output Format

For each test case: output one line containing an integer, the maximum product after splitting nn modulo 10910^9.

3
5
8
100
6
18
755407364

Hint

For 40%40\% of the test cases, it is guaranteed that n50n\leq 50.

For all test cases, it is guaranteed that 1t1041\leq t\leq 10^4 and 1n1061\leq n\leq 10^6.

Translated by ChatGPT 5