#P1479. Counting Complete Lines on a 5x5 Board
Counting Complete Lines on a 5x5 Board
Counting Complete Lines on a 5x5 Board
In a 5×5 board, you are given an integer n (5 ≤ n ≤ 25). You must place n pieces on distinct cells of the board. A complete line (or five‐in‐a‐row) is defined as any row, column, or diagonal whose 5 cells are all occupied by a piece. Note that there are 12 such lines (5 rows, 5 columns, and 2 diagonals) on a 5×5 board.
Different placements of the n pieces might result in a different number k of complete lines. Let the set of distinct k values (over all placements) be considered. Your task is to compute and output the sum of these distinct k values.
For example, when n = 11, it turns out that the only two distinct k values that occur are 1 and 2, so the answer is 1 + 2 = 3.
inputFormat
The input consists of a single integer n (5 ≤ n ≤ 25), representing the number of pieces placed on the board.
outputFormat
Output a single integer: the sum of all distinct numbers of complete lines (k) that appear among all valid placements.
sample
5
1