b266: Bowling Frame
標籤 :
通過比率 : 1人/1人 ( 100% ) [非即時]
評分方式:
Tolerant

最近更新 : 2025-08-08 23:02

內容

Bowling is a national sport in Taiwan; everyone in the country plays the sport on a daily basis since their youth. Naturally, there are a lot of bowling alleys all over the country, and the competition between them is as intense as you can imagine.

Maw-Shang owns one such bowling alley. To stand out from other competitors in the industry and draw attention from customers, he decided to hold a special event every month that features various unorthodox bowling rules. For the event this month, he came up with a new version of the game called X-pin bowling. In the traditional 10-pin bowling game, a frame is built out of ten bowling pins forming a triangular shape of side length four. The pin closest to the player forms the first row, and the two pins behind it form the second row, and so on. Unlike the standard version, the game of X-pin bowling Maw-Shang designed allows a much larger number of pins that form a larger frame. The following figure shows a standard 10-pin frame on the left, and on the right it shows a 21-pin frame that forms a triangular shape of side length six which is allowed in the game of X-pin bowling.

Being the national sport, the government of Taiwan strictly regulates and standardizes the manufacturing of bowling pins. There are two types of bowling pins allowed, one in black and the other in white, and the bowling alley Maw-Shang owns has w white pins and b black pins. To make this new game exciting for the customers, Maw-Shang wants to build the largest possible frame from these w+b pins. However, even though he is okay with using both colors in building the frame, for aesthetic reasons, Maw-Shang still wants the colors of the pins on the same row to be identical. For example, the following figure shows two possible frames of side length six, but only the left one is acceptable to Maw-Shang since the other one has white and black pins mixed in the third row.

The monthly special event is happening in just a few hours. Please help Maw-Shang calculate the side length of the largest frame that he can build from his w+b pins!

輸入說明

The first line of the input contains a single integer t, the number of test cases. Each of the following t lines contains two integers w and b, the number of white and black pins, respectively.

  • 1≤ t ≤100
  • 0≤ w,b ≤109
輸出說明

For each test case, output in a single line the side length k of the largest pin satisfying Maw-Shang's requirement you can build with the given pins.

範例輸入
4
1 2
3 2
3 3
12 0
範例輸出
2
2
3
4
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1M
提示 :

2024 ICPC Asia Taichung Regional Contest - B. Bowling Frame

標籤:
出處:
[管理者:
eedwang (37831楊珈瑜)
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」