포럼
문제 ICPC00219

K. Klompendans

설명

In traditional Dutch clog dancing, you as the dancer need to follow a very specific sequence of movements. The dance takes place on a square grid of square tiles, and at the start of the dance you stand on the top left corner tile of the grid. You then alternate between two types of dance move, moving from tile to tile in the grid for as long as you want. Your first move may be of either kind, but after that you need to strictly alternate between the two kinds of moves.

Both moves are similar to knight moves in chess: in the first type of move, you go from your current square to a square that is \(a\) tiles away along one axis of the grid and \(b\) tiles away along the other axis. Similarly, in the second type of move, you need to move \(c\) and \(d\) tiles along the respective axes. As you can freely swap the two axes and choose the movement direction along each axis, there can be up to \(8\) ways of performing a given type of move. Figure shows an example dance routine with \((a,b) = (1,2)\) and \((c,d) = (2,3)\).

Starting on the top left corner tile, how many different tiles could you reach while doing a clog dance? It is not allowed to step outside of the grid and you do not count tiles that you are simply stepping over while doing a move. Note that you need to count all tiles that can be reached during some performance of the dance, but not necessarily during the same one.

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(3\leq n\leq 500\)), the side length of the square.
- One line with two integers \(a\) and \(b\) (\(1\leq a, b < n\)), describing the first dance move.
- One line with two integers \(c\) and \(d\) (\(1\leq c, d < n\)), describing the second dance move.

출력 형식

Output the number of tiles you can reach using these dance moves.

예제 1
입력
3
2 1
2 2
출력
6
예제 2
입력
8
1 2
1 2
출력
64
예제 3
입력
4
1 2
2 3
출력
13
예제 4
입력
5
1 2
2 3
출력
25
예제 5
입력
10
3 3
4 4
출력
50
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2023

평가 및 의견

K. Klompendans

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

K. Klompendans

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8