#P1736. Yet Another Problem About Pi

Yet Another Problem About Pi

题目描述

On a distant planet of dreams, Toilet-Ares is packing up the things and memories, ready to commerce a new adventurous road trip. With outstanding driving skills, the driving route may be a segment, a curve, a polyline, and it can be closed (end-to-end), even self-intersect, as long as the route is continuous. The fuel capacity, oddly enough, can support pi\\pi km driving. Thus, the route has a maximum total length of pi\\pi km.

The planet's surface is expansive and flat enough to regard as a plane. A Cartesian coordinate system, formed with longitude and latitude, is used to describe each geographical position on the planet. Every ww km, draw a line of points with some equal longitude, named meridian. Similarly, every dd km, draw a line of points with some equal latitude, named parallel. Notice that innumerous meridians are perpendicular to innumerous parallels, constructing a grid called graticule, dividing the plane into infinite cells. Inhabitants there are used to defining those cells as regions, and to avoid conflict, positions on meridians or parallels belong to no region.

There are so many different kinds of landscapes to see, to admire, to experience. Toilet-Ares starts the drive at an arbitrary position on the planet. Whenever passing a region for the first time, Toilet-Ares will remember its visual feature (which is always distinguishable from any other region). So, it will be easy for Toilet-Ares to count up the number of regions visited as the road trip ends.

For example, in both situations shown below, four different regions are visited along the route.

链接:https://ac.nowcoder.com/acm/contest/11259/K 来源:牛客网

Just as the saying goes, "Where there is a will, there is a way." Toilet-Ares always attempts to figure out how many different regions at most can visit in the whole road trip. And you, as a friend, are here to answer this question.

输入格式

The input contains multiple test cases. The first line of input contains one integer TT (1leTle1051 \\le T \\le 10^5).

In the following TT lines, each line contains two real numbers w,d(0<w,dle5)w,d (0 < w,d \\le 5), describing one test case. Any of them may be an integer or contains at most 8 decimal digits. It is guaranteed that there is no trailing zero in decimal place.

输出格式

For each test case, output the corresponding answer with an integer in one line.

样例

2 
5 5 
1.5 1.5
4 
8

提示

来自:2021牛客暑期多校训练营8

搬运by FrankOu