Back
Close

thief minor

Statement

 Goal

A boss hired N miners to harvest gold in his mine. They must make several ingots of Weight grams of gold each. The boss realizes that some of the ingots contain only ThiefWeight grams of gold. One miner is cheating and making smaller ingots in order to steal the leftover gold.

The boss does not know which miner it is. Fortunately he remembers the solution to this classic puzzle. https://www.popularmechanics.com/technology/a24023/riddle-of-the-week-4/

He brings all the miners together with their carts filled with the ingots they produced. He aligns them in a row and asks them not to move. Then the boss performs a single weighing giving him G grams allowing him to know who is the thief.

Determine the thief's position in the row.
Input
Ligne 1 : Integer N number of miners
Ligne 2 : Integer Weight grams of ingots
Ligne 3 : Integer ThiefWeight grams of thief's ingots
Ligne 4 : Integer G grams of weighed
Output
Ligne 1 : integer the thief's position in the ranks
Constraints
2 ≤ N ≤ 100
100 ≤ Weight ≤ 10000
1 ≤ ThiefWeight ≤ 9999
ThiefWeight] < Weight
Example
Input
7
1000
900
27300
Output
7

Tags

Difficulty
Easy

Test cases
Test 1 Test
Input
7 1000 900 27300
Output
7

Validator 1 Validator
Input
7 100 90 2730
Output
7

Test 2 Test
Input
10 100 50 5250
Output
5

Validator 2 Validator
Input
10 10 5 525
Output
5

Test 3 Test
Input
98 9800 8900 47477700
Output
69

Validator 3 Validator
Input
98 9800 8900 47476800
Output
70

Test 4 Test
Input
69 2 1 4808
Output
22

Validator 4 Validator
Input
69 4 1 9594
Output
22

Solution language

Solution

Stub generator input