#P797. Shovels and Swords ( 鏟和劍 )

    ID: 797 Type: Default 400ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>1100BASICn行t行Educational Codeforces Round 89

Shovels and Swords ( 鏟和劍 )

題目描述

Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.

Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?

Polycarp 玩一個著名的電腦遊戲(我們不會提及它的名字)。 在這個遊戲中,他可以製作兩種工具 — 鏟和劍。 為了製作一把鏟子,Polycarp 花費了兩根木棍和一顆鑽石; 為了製作一把劍,Polycarp 花費了兩顆鑽石和一根棍子。

每件工具只能賣一個綠寶石。 如果Polycarp 有 a 條木棍和 b 粒鑽石,他能賺多少綠寶石?

輸入格式

The first line contains one integer t (1≤t≤1000) — the number of test cases.

The only line of each test case contains two integers a and b (0≤a,b≤109) — the number of sticks and the number of diamonds, respectively.

第一行包含一個整數 t (1≤t≤1000) — 測試用例的數量。

每個測試用例的唯一一行包含兩個整數 a 和 b (0≤a,b≤109) — 分別是棍子的數量和鑽石的數量。

輸出格式

For each test case print one integer — the maximum number of emeralds Polycarp can earn.

對於每個測試用例,打印一個整數 — Polycarp 可以獲得的綠寶石的最大數量。

Samples

4
4 4
1000000000 0
7 15
8 7
2
0
7
5

提示

In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.

In the second test case Polycarp does not have any diamonds, so he cannot craft anything.

在第一個測試案例中,Polycarp 可以獲得兩顆綠寶石,如下所示:製作一把劍和一把鏟子。

在第二個測試案例中,Polycarp 沒有任何鑽石,因此他無法製作任何東西。

原始資料

  • Zero1 題號:a797
  • Hydro 題號:Z0797
  • Locale:zh_TW
  • Display:open