Chef Wars - Return of the Jedi Problem Code: CHEFWARS

 

Read problem statements in Hindi, Bengali, Mandarin Chinese, Russian, and Vietnamese as well.

On the ice planet Hoth, Chef has run into his arch-nemesis, DarthForces. Darth has a peculiar fighting style ― he does not attack, but simply defends and lets his opponent tire himself out.

Chef has a lightsaber which has an attack power denoted by . He keeps hitting Darth with the lightsaber. Every time he hits, Darth's health decreases by the current attack power of the lightsaber (by  points), and afterwards, decreases to .

If the attack power becomes  before Darth's health becomes  or less, Chef dies. Otherwise, Darth dies. You are given Darth's initial health  and the initial attack power . Tell Chef if he can beat Darth or if he should escape.

Input

  • The first line of the input contains a single integer  denoting the number of test cases. The description of  test cases follows.
  • The first and only line of each test case contains two space-separated integers  and .

Output

For each test case, print a single line containing the integer  if Chef can beat Darth or  otherwise.

Constraints

Subtasks

Subtask #1 (100 points): original constraints

Example Input

2
10 4
10 8

Example Output

0
1

Explanation

Example case 1: Chef attacks with power , Darth's health becomes . Chef attacks with power , Darth's health becomes . Chef attacks with power  and Darth's health becomes , but Chef's attack power becomes .

Example case 2: Chef attacks with power , Darth's health becomes . Chef attacks with power , Darth's health becomes . Chef kills Darth.


Comments

Popular posts from this blog

Access and modify all the resources of our Wiki.js using WikiJS API

MySQL Multi Source Master Slave Replication using GTID

How to pass parameters in webhook?