`{"id":"f6c4fcdf-253b-4839-8b89-dcc3f0c746bc","name":"Find Water In Glass","description":"1. Pepcoder arranged some glasses in the form of pascal triangle.\r\n2. Capacity of each glass is 1 litre. If you pour K amount of water in a glass, it will retain 1 litre and\r\n rest of it gets equally distributed in left bottom glass and right bottom glass.\r\n3. If pepcoder pours K litres of water in the topmost glass, you have to find out the amount of water in Cth glass of Rth row.\r\n\r\nAssumption -> There are enough glasses in the triangle till no glass overflows.","inputFormat":"A number K representing amount of water poured in topmost glass.\r\nTwo numbers R and C","outputFormat":"A number representing the amount of water present in Cth glass of Rth row.","constraints":"1 &lt;= K &lt;= 500\r\n1 &lt;= R,C &lt;= K","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static double solution(int k, int r, int c) {\r\n // write your code here\r\n\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int k = scn.nextInt();\r\n int r = scn.nextInt();\r\n int c = scn.nextInt();\r\n System.out.println(solution(k, r, c));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n1\r\n0","sampleOutput":"1.0\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"351ded63-248f-4ca0-b6bd-1ef265a86635","name":"Find Water In Glass","slug":"find-water-in-glass","type":1}],"next":{"id":"0565ef75-6d57-441e-979e-94ffeff63c46","name":"Frog Jump","type":1,"slug":"frog-jump"},"prev":{"id":"ec56da72-5df8-4ddc-a8ec-8437d7aea490","name":"Interleaving of Two Strings MCQ","type":0,"slug":"interleaving-of-two-strings-mcq"}}}`

# Find Water In Glass

1. Pepcoder arranged some glasses in the form of pascal triangle. 2. Capacity of each glass is 1 litre. If you pour K amount of water in a glass, it will retain 1 litre and rest of it gets equally distributed in left bottom glass and right bottom glass. 3. If pepcoder pours K litres of water in the topmost glass, you have to find out the amount of water in Cth glass of Rth row. Assumption -> There are enough glasses in the triangle till no glass overflows.

`{"id":"f6c4fcdf-253b-4839-8b89-dcc3f0c746bc","name":"Find Water In Glass","description":"1. Pepcoder arranged some glasses in the form of pascal triangle.\r\n2. Capacity of each glass is 1 litre. If you pour K amount of water in a glass, it will retain 1 litre and\r\n rest of it gets equally distributed in left bottom glass and right bottom glass.\r\n3. If pepcoder pours K litres of water in the topmost glass, you have to find out the amount of water in Cth glass of Rth row.\r\n\r\nAssumption -> There are enough glasses in the triangle till no glass overflows.","inputFormat":"A number K representing amount of water poured in topmost glass.\r\nTwo numbers R and C","outputFormat":"A number representing the amount of water present in Cth glass of Rth row.","constraints":"1 &lt;= K &lt;= 500\r\n1 &lt;= R,C &lt;= K","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static double solution(int k, int r, int c) {\r\n // write your code here\r\n\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int k = scn.nextInt();\r\n int r = scn.nextInt();\r\n int c = scn.nextInt();\r\n System.out.println(solution(k, r, c));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n1\r\n0","sampleOutput":"1.0\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"351ded63-248f-4ca0-b6bd-1ef265a86635","name":"Find Water In Glass","slug":"find-water-in-glass","type":1}],"next":{"id":"0565ef75-6d57-441e-979e-94ffeff63c46","name":"Frog Jump","type":1,"slug":"frog-jump"},"prev":{"id":"ec56da72-5df8-4ddc-a8ec-8437d7aea490","name":"Interleaving of Two Strings MCQ","type":0,"slug":"interleaving-of-two-strings-mcq"}}}`

Editor

# Find Water In Glass

medium

1. Pepcoder arranged some glasses in the form of pascal triangle. 2. Capacity of each glass is 1 litre. If you pour K amount of water in a glass, it will retain 1 litre and rest of it gets equally distributed in left bottom glass and right bottom glass. 3. If pepcoder pours K litres of water in the topmost glass, you have to find out the amount of water in Cth glass of Rth row. Assumption -> There are enough glasses in the triangle till no glass overflows.

## Constraints

1 <= K <= 500 1 <= R,C <= K

## Format

### Input

A number K representing amount of water poured in topmost glass. Two numbers R and C

### Output

A number representing the amount of water present in Cth glass of Rth row.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}3 1 0```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}1.0 ```

Discussions

Show Discussion

Related Resources