포럼
문제 ICPC00390

A. Around the Table

설명

Emilia and her brother Alex meet up with a lot of friends in the park to play table tennis together. Since there is only one table, they play round-the-table which is everybody's favourite.

The rules are simple: There are \(\ell \geq 2\) kids queueing up on the left side and \(r \geq 1\) kids queueing up on the right side of the table. The first kid on the left side starts with the ball. Whoever has the ball hits it over the net onto the opposite side and runs around the table to join the queue at the opposite side. This is repeated until the first mistake.

Emilia, Alex, and their friends play this game all the time and are so good that they can go on almost forever without making any mistake. After some time, Emilia notices that she has never faced Alex, meaning that they have never been at the front of opposite queues at the same time. She wonders if this will ever happen in this round. Curious about this, she starts keeping track which pairings have already faced each other.

How many different pairings has she counted after the ball went over the net \(10^{10^{100}}\) times?

제약
입력 형식

The input consist of:
- One line with two integers \(\ell\) and \(r\) (\(2 \leq \ell \leq 10^{9}\) and \(1 \leq r \leq 10^{9}\)), the number of players on the left and right side of the table, respectively.

출력 형식

Output the number of different pairings Emilia counts.

예제 1
입력
2 2
출력
6
예제 2
입력
2 3
출력
10
예제 3
입력
3 2
출력
5
예제 4
입력
5 2
출력
14
문제 정보

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

출처 ICPC GCPC 2025

평가 및 의견

A. Around the Table

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

Log in to rate problems.

개별 의견

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

풀이 제출

A. Around the Table

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