Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chess Game Bob loves chess so one day he asked his brother a simple problem of chess in which his brother need to calculate the

image text in transcribed

image text in transcribed

image text in transcribed

Chess Game

Bob loves chess so one day he asked his brother a simple problem of chess in which his brother need to calculate the number of ways to place N rooks on Nx N chessboard such that the below conditions should met

1. All the empty cell of chessboard should under the attack 2. Exactly K pair of rooks should attack each other.

Note:

1. Two ways to place the rooks are considered different if there exists at least one cell which is empty in one of the ways but contains a rook in another way.

2. An empty cell of chessboard is under attack if there is at least one rook in the same row or at least one rook in the same column. Two rooks attack each other if they share the same row or column, and there are no other rooks between them

The answer might be large, so print it modulo 998244353

Input

The only line of the input contains two integers N and K

Output

Print the number of ways to place the rooks, taken modulo 998244353

Examples

Input

Output

6

Input

33

Output

0

Input

40

Output

24

Sample input.

32

Sample Output

6

Note:

Your code must be able to print the sample output from the provided simple input. However your code is run against multiple hidden test cases. Therefore your code must poss these hidden test cases to solve the problem statement

Limits

Time Limit: 2.0 secy for each input file Memory Limit 256 MB

Source Limit 1024 KB

Scoring

Score assigned if any testcase paises

NOTE: SOLVE IN 25 MINUTES.

Max. score: 100.00 New SUD Question 2 Au Chess Game 1 Bob loves chess so one day he asked his brother a simple problem of chess in which his brother need to calculate the number of ways to place N rooks on NXN chessboard such that the below conditions should met 1. All the empty cell of chessboard should under the attack 2. Exactly K pair of rooks should attack each other. Note: 1. Two ways to place the rooks are considered different if there exists at least one cell which is empty in one of the ways but contains a rook in another way. "l 2. An empty cell of chessboard is under attack if there is at least one rook in the same row or at least one rook in the same column. Two rooks attack each other if they share the same row or column, and there are no other rooks between them The answer might be large, so print it modulo 998244353 Input The only line of the input contains two integers N and K Output Print the number of ways to place the rooks, taken modulo 998244353 Examples Input Output IN Print the number of ways to place the rooks, taken modulo 998244353 Examples 1 Input 32 Output 6 Input 33 - Output O Input 40 Output 24 E Sample output Sample input 6 32 0 II Input 40 Output 24 Sample input UTI E Sample output 32 -Il- Note: Your code must be able to print the sample output from the provided sample input However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement. Limits Time Limit: 20 sec(s) for each input file Memory Limit 256 MB Source Limit: 1024 KB Scoring Score is assigned if any testcase passes Allowed Languages C, CH, C++14, Java, Python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Develop a program for effectively managing diversity.

Answered: 1 week ago

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago