2364 - I2P(I)2020_Chen_bonus4 Scoreboard

Time

2021/05/25 21:30:00 2021/06/01 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12178 Queens and Castles

12178 - Queens and Castles   

Description

Long long long long long long long long long long time ago, there's a lovely kingdom named "Chess". There's King, Queen, Knight, Castle, Bishop, ...etc. Just like the modern game "chess". 

A king possessed one or more castles, and likewise a king could have two or more queens (same as queen, a queen is able to have two or more kings). Now in this kingdom, the king has N queens and M castles. All the castles are male, and of course, all the queens are female. 

Moreover, the queen would eventually fall in love with castles, castles would eventually fall in love with queens, queens would eventually fall in love with other queens, castles would eventually fall in love with other castles.(This is a diversified world, BL or GL could happen.) Queens and castles concerned that if the king found betrayal by which giving a large green hat, they will not be forgiven. 

Queens and castles assign a secret mission to you, the mightily programming knight. They'd like to figure out the possibilities that the king was unaware their relationship in the palace.


  • There are N queens and M castles in the palace.
  • The palace is just like a chessboard with size (N+M)*(N+M). 
  • Queen can see all people in 8 directions(←, ↑, →, ↓, ↖, ↗, ↘, and ↙. Just like what queen in the chess does). If any queen see castles or other queens, the mission will fail. 
  • Castle can see all people in 4 directions(←, ↑, →, and ↓. Just like what castle in the chess does). If any castle see queens or other castles, the mission will fail. 
  • Find out the total amount of states that all queens and castles are placed in the palace and mission isn't fail.

Input

The input contains exactly two numbers N and M, each seperated by a space. 

1 <= N+M <= 9.

Output

Output only one number ── the total amount of states that queens and castles are placed in the palace and mission isn't fail.

Remember to print a '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss