Great Sequences
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Great Sequences
Problem Statement
Farmer John's farm is home to cows, each identified by a unique name represented as a positive integer from to .
John is interested in creating pairs of sequences, each of length . Each sequence is built with the cows' names. A pair of sequences, $(S, T) = ((S_1, S_2, \dots , S_M), (T_1, T_2, \dots , T_M))$, earns the title of a 'beautiful pair' if it satisfies the following condition:
- There exists a binary sequence of length . For this sequence, at every index from to , the element of is different from the element of .
With possible pairs of sequences of length using the cows' names, John is curious about the number of 'beautiful pairs' he can create.
Given the large number of possible sequences, he wants the answer modulo .
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains two integers and .
OUTPUT FORMAT (print output to the terminal / stdout):
Output a single integer: the number of "beautiful pairs" of sequences, modulo . The sequences should be of length and consist of positive integers no greater than .
SAMPLE INPUT 1:
3 2
SAMPLE OUTPUT 1:
36
For example, if sequence is , and sequence B is , then is a beautiful pair of sequences. Indeed, if we set to be , then is a binary sequence of length consisting of and that satisfies the condition where the element of is different from the element of for every index from to . Thus, satisfies the condition of being a beautiful pair of sequences.
There are a total of beautiful pairs of sequences, so we print this number.
SAMPLE INPUT 2:
20 231104
SAMPLE OUTPUT 2:
966200489
SCORING:
- Inputs 3-7:
- Inputs 8-10:
- Inputs 11-20: No additional constraints.
HFI Coding Club 2023 November Contest
- Status
- Done
- Rule
- IOI
- Problem
- 4
- Start at
- 2023-11-16 18:45
- End at
- 2023-11-16 20:45
- Duration
- 2 hour(s)
- Host
- Partic.
- 21