nCr mod 10^9 + 7 for n<=10^9 and r <=1000 [closed] - time-complexity

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
This may have been asked before but none of the answers I saw worked for me. I tried Lucas Theorem,Fermat's theorem but none of them worked. Is there an efficient way to find the value of:
nCr mod 10^9+7 where n<=10^9 and r<=1000
Any help will be very useful

n is large while r is small, you are better off compute nCr by n(n-1)...(n-r+1)/(1*2*...*r)
You may need to find multiplicate inverse of 1, 2, ... r mod 10^9+7

Related

Calculus with Constants [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
An electric current, I, in amps, is given by
I=cos(wt)+√(8)sin(wt),
where w≠0 is a constant. What are the maximum and minimum values of I?
I have tried finding the derivative, but after that, I do not know how to solve for 0 because of the constant w.
Well David,you can convert this function into one trigonometric function by multiplying and dividing it by
√(1^2 + 8) i.e, 3. So your function becomes like this
I = 3*(1/3 cos(wt) + √8/3 sin(wt))
= 3* sin(wt + atan(1/√8))
Now, you can easily say its maximum value is
I = 3 amp
and minimum value is
I = 0 amp.

Objective C: Do I have to import arc4random ( )? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to generate a random number between 0 and 3 by saying
int i = arc4Random() % 3;
but it keeps giving me the warning "implicit declaration of function 'arc4Random' is invalid in c99
Try it without the capital r
int i = arc4random() % 3;
You have a capital "R" in arc4Random. Should be: int i = arc4random % 3;.

Confused to get that 2^(n^2 )=Θ(2^(n^3 ))? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Can anyone help me to understand that Is 2^(n^2 )=Θ(2^(n^3 )) ? it will be great if also provide the proof for this. As per my view this does not need to be equal.
The given assumption is not true:
First of all, 2^(n^2) is a function and Theta(2^(n^3)) is a set of functions, so it would be correct to say that 2^(n^2) ∈ Theta(2^(n^3)). The = is just a common abuse of notation, but it actually means ∈. To find out whether that statement is true, solve the following limit:
lim (n->infinity) of (2^(n^2)) / (2^(n^3))
If the result is 0 or infinite then the function does not belong to that particular Theta class. If it is some other value, it does belong to that class.

What is "fabs" in Objective C? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
Found this bit of code...
if(fabs([tempPlacemark getCoordinate].latitude-latitude) < latDelta && fabs([tempPlacemark getCoordinate].longitude-longitude)<longDelta )
...
refers to this in Math.h:
extern float fabsf(float);
extern double fabs(double);
extern long double fabsl(long double);
So what am I looking at?
double fabs( double ) - returns the absolute value of the argument
NSLog(#"res: %.f", fabs(10)); //result 10
NSLog(#"res: %.f", fabs(-10)); //result 10
found here.

Why do 2 and 3 equal 2 in VBA? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
If you evaluate the following in VBA, the output is True:
(2 And 3) = 2
Can someone explain this to me? Thanks!
You have:
2 (base 10) == 10 (base 2)
3 (base 10) == 11 (base 2)
Performing a bitwise AND gives
10 (base 2) == 2 (base 10)
0 = false, everything else is true in VB
I tried to find some link for MS that explained this but I could not.