The Divisibility Dilemma Code Techgig Geek Goddess Solution
100% Working Code uploaded on Youtube: https://youtu.be/6cn7nNtSiKo
100% Working Code uploaded on Telegram: https://telegram.me/PLACEMENTLELO
The Divisibility Dilemma (100 Marks)
In the picturesque village of Numeropolis, the annual "Divisibility Day" is celebrated with great enthusiasm. This day is marked by various mathematical challenges and games that put the villagers' arithmetic skills to the test. This year, the villagers are embarking on a quest to explore the distinctive properties of subarrays within integer arrays.
The village's renowned mathematician, Professor Arithmo, has crafted an intriguing challenge. He has provided the villagers with an integer array nums`and two additional integers, K and P. Professor Arithmo's challenge revolves around discovering and counting distinct subarrays from the array nums. The uniqueness of these subarrays is determined by their divisibility characteristics.
Specifically, Professor Arithmo asks the villagers to identify subarrays that have no more than K elements divisible by P. To put it simply, a subarray is considered valid if the count of elements divisible by P within it does not exceed K.
In Numeropolis, the concept of distinctiveness extends to subarrays as well. Two subarrays, subarray1 and subarray2, are said to be distinct under the following conditions:
1. They possess different lengths.
2. There is at least one index i where subarray1[i] is not equal to subarray2[i].
To assist the villagers in this quest, you are tasked with calculation of count of distinct subarrays that satisfy the divisibility condition and the distinctiveness condition.
Input Format
First line contains three space-separated integers N, K and P respectively.
Second line contains N space-separated integers representing elements of array nums.
Constraints
1 <= N <= 200
1 <= nums[i], P <= 200
1 <= K <= N
Output Format
Print a single integer representing the count of distinct subarrays.
Sample TestCase 1
Input
4 1 2
3 4 5 6
Output
8
Explanation
There are a total of 8 subarrays following the condition:
{ 3 }
{ 3, 4 }
{3, 4, 5}
{ 4 }
{ 4, 5 }
{ 5 }
{ 5, 6 }
{ 6 }
Time Limit(X): 0.50 sec(s) for each input.
Memory Limit: 512 MB
Source Limit: 100 KB
Allowed Languages:
C, C++, C++11, C++14, C#, Java, Java 8, Kotlin, PHP, PHP 7, Python, Python 3, Perl, Ruby, Node Js, Scala, Clojure, Haskell, Lua, Erlang, Swift, VBnet, Js, Objc, Pascal, Go, F#, D, Groovy, Tcl, Ocaml, Smalltalk, Cobol, Racket, Bash, GNU Octave, Rust, Common LISP, R, Julia, Fortran, Ada, Prolog, Icon, Elixir, CoffeeScript, Brainfuck, Pypy, Lolcode, Nim, Picolisp, Pike, pypy3
100% Working Code uploaded on Youtube: https://youtu.be/6cn7nNtSiKo
100% Working Code uploaded on Telegram: https://telegram.me/PLACEMENTLELO
Comments
Post a Comment