Fast n choose k mod p for large n?

So, here is how you can solve your problem. Of course you know the formula: comb(n,k) = n!/(k!*(n-k)!) = (n*(n-1)*…(n-k+1))/k! (See http://en.wikipedia.org/wiki/Binomial_coefficient#Computing_the_value_of_binomial_coefficients) You know how to compute the numerator: long long res = 1; for (long long i = n; i > n- k; –i) { res = (res * i) % p; } Now, … Read more

Why is −1 > sizeof(int)?

The following is how standard (ISO 14882) explains abort -1 > sizeof(int) Relational operator `>’ is defined in 5.9 (expr.rel/2) The usual arithmetic conversions are performed on operands of arithmetic or enumeration type. … The usual arithmetic conversions is defined in 5 (expr/9) … The pattern is called the usual arithmetic conversions, which are defined … Read more

How to create a modular JSF 2.0 application?

I understand that your question basically boils down to How can I include Facelets views in a JAR? You can do this by placing a custom ResourceResolver in the JAR. public class FaceletsResourceResolver extends ResourceResolver { private ResourceResolver parent; private String basePath; public FaceletsResourceResolver(ResourceResolver parent) { this.parent = parent; this.basePath = “/META-INF/resources”; // TODO: Make … Read more