Chef and Subsequences - CodeChef
Chef and Subsequences - CodeChef
(/users/gaurav_jain21)
Tweet Like Share One person likes this. Sign Up to see what your friends
like.
(http://www.codechef.com/download/translated/MAY17/russian/CHEFCODE.pdf)
and vietnamese
(http://www.codechef.com/download/translated/MAY17/vietnamese/CHEFCODE.pdf)
as well.
Though our Head Chef retired from sport programming long back, but that did not affect
his passion to contribute to the programming community. He still remains engaged by
creating new problems and passing it on to the online judges. Last Night, he thought of a
following problem for which he could not figure out a solution. You being his friend from
the older days of programming decide to help him.
Find the number of non-empty subsequences in the given list of N integers such that the
product of the values in the subsequences does not exceed K
Input
First line of the input will contain two space separated integers N and K. Next and last
line of the input contains N space separated integers
Output
Print the answer to the given test case in a separate line.
Constraints
1 N 30
1 K, Ai 10^18
Subtasks
Subtask #1 : (30 points)
1 N 10
1 N 30
Example
Input:
3 4
1 2 3
Output:
5
Explanation
For the given sample case, there are 7 non-empty subsequences out of which 2 have
their product > 4. Those include {2, 3} and {1, 2, 3}. Hence, the answer is 7 - 2 = 5.
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP
4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK,
ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS,
PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH,
PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST,
TCL, TEXT, WSPC
Submit (/MAY17/submit/CHEFCODE)
Comments
2009 Directi Group (http://directi.com). All Rights Reserved. CodeChef uses SPOJ by Sphere Research Labs (http://www.sphere-research.com)
In order to report copyright violations of any kind, send in an email to [email protected] (mailto:[email protected])
(http://directi.com)
FAQ's (https://www.codechef.com/wiki/faq)
Initiatives
Go for Gold (http://www.codechef.com/goforgold)
Domain Registration in India (http://www.bigrock.in/) and Web Hosting (http://www.bigrock.com/web-hosting/) powered by BigRock