Neeraj_Kumar_Coder's blog

By Neeraj_Kumar_Coder, history, 4 months ago, In English

Statement

It's the world tourism day and agoda has launched a special promocode with each hotel booking a person makes, they can get a cashback randomly and uniformly distributed from the range [1, maxCashback] in integer USD. A person will start with 0 cashback and can keep applying this promocode until they secure a minimum of M USD in total across all his future bookings.
To keep the customers happy, Agoda wants to ensure that majority of people can make atleast H USD from this promocode.
Find the probability of a customer being not happy (total cashback < H) with this promocode. Given M, maxCashback, H.

Constraints

0 <= M <= H <= 1e4
1 <= maxCashback <= 1e4

Output

The calculated probability

SAMPLE TEST CASE

1 10 6

OUTPUT

0.50000

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -4
  • Vote: I do not like it

By Neeraj_Kumar_Coder, history, 4 months ago, In English

Statement

You are given an array consisting of only 0, 1 and 2. Also given two integers x and y. Your task is to find the number of subarrays with ratio of frequency of 0 and 1 being x : y.

Input

The first line of input contains and integer n, denoting the number of elements in the array.
The next line contains n space separated integers denoting elements of array.
The next line contains two integers x and y.

Output

Output the number of subarrays having 0's and 1's in the ratio x : y.

CONSTRAINTS

2 <= n <= 1e5
1 <= x, y <= n

SAMPLE TEST CASE

5
0 1 2 0 1
1 1

OUTPUT

6

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -11
  • Vote: I do not like it