描述
Little Rosie has a phone with a desktop (or launcher, as it is also called). The desktop can consist of several screens. Each screen is represented as a grid of size?5×3, i.e., five rows and three columns.
There are?x?applications with an icon size of?1×1?cells; such an icon occupies only one cell of the screen. There are also?y?applications with an icon size of?2×2?cells; such an icon occupies a?square?of?4?cells on the screen. Each cell of each screen can be occupied by no more than one icon.
Rosie wants to place the application icons on the minimum number of screens. Help her find the minimum number of screens needed.
輸入描述
The first line of the input contains?t?(1≤t≤104)?— the number of test cases.
The first and only line of each test case contains two integers?x?and?y?(0≤x,y≤99)?— the number of applications with a?1×1?icon and the number of applications with a?2×2?icon, respectively.
輸出描述
For each test case, output the minimal number of required screens on a separate line.
用例輸入 1?
11 1 1 7 2 12 4 0 3 1 0 8 1 0 0 2 0 15 0 8 2 0 9
用例輸出 1?
1 1 2 2 1 1 0 1 1 2 5
提示
The solution for the first test case can look as follows:
Blue squares represent empty spaces for icons, green squares represent?1×1?icons, red squares represent?2×2?icons
The solution for the third test case can look as follows:
?翻譯:
描述
小羅茜有一部帶桌面(或啟動器,也稱為啟動器)的手機。桌面可以由多個屏幕組成。每個屏幕都表示為大小的網格5×3,即五行三列。
有x圖標大小為1×1細胞;這樣的圖標只占據屏幕的一個單元格。還有和圖標大小為2×2細胞;這樣的圖標占據了一個正方形4屏幕上的單元格。每個屏幕的每個單元格只能被一個圖標占據。
Rosie 希望將應用程序圖標放置在最少數量的屏幕上。幫助她找到所需的最小屏幕數量。
輸入描述
輸入的第一行包含t?(1≤噸≤104) — 測試用例的數量。
每個測試用例的第一行也是唯一的一行包含兩個整數x和和?(0≤?x,y≤99) — 具有1×1圖標和帶有2×2圖標。
輸出描述
對于每個測試用例,在單獨的行上輸出所需屏幕的最小數量。
用例輸入 1?
11
1 1
7 2
12 4
0 3
1 0
8 1
0 0
2 0
15 0
8 2
0 9
用例輸出 1?
1
1
2
2
1
1
0
1
1
2
5
提示
第一個測試用例的解決方案可以如下所示:
藍色方塊表示圖標的空白區域,綠色方塊表示1×1圖標,紅色方塊代表2×2圖標
第三個測試用例的解決方案如下所示:
?解題思路:
?先根據大的判斷屏幕,一個屏幕最多倆大的,然后根據小的增加屏幕
c++代碼如下:
#include <bits/stdc++.h>using namespace std;int main()
{int n;cin >> n;while(n--){int small,big;cin >> small >> big;int res = 0;res = big/2 + big%2;if(small > 15*res - big*4){small -= 15*res - big*4;res += small/15 + (small%15 != 0);}cout << res << endl;}
}