The final sequence should be (0,0),(1,1),(2,3),(3,5),(5,8)...
(0,0) and (0,1) both finishes in 0 iteration.
(1,2)-(0,1) and (1,1)-(0,1) both finishes in 1 iteration.
So (0,1) and (1,2) is discarded.
For the rest: (0,1) - (1,2) - (2,3) - (3,5) - (5,8) - ...
finishes in:
Code::Blocks
On Sun, May 29, 2011 at 1:59 AM, Akash Mukherjee akash...@gmail.com wrote:
devcpp
On Sat, May 28, 2011 at 11:17 PM, sravanreddy001 sravanreddy...@gmail.com
wrote:
Hi all. Can some one provide a good C editor.. preferable GUI one, that
works on windows 7.
I'm good with
My code gives TLE. What further optimization is required in my code??
https://www.spoj.pl/problems/FACVSPOW/
/*FACVSPOW*/
#includestdio.h
#includecmath
using namespace std;
int calc(long n, long a)
{
if(((n*log(n)-n)+0.5*log(2*M_PI*n)-n*log(a))=0)
return 1;
else return -1;
}
int main()
{
Precompute the values. and then do queries.
On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma
akshatasharm...@gmail.comwrote:
My code gives TLE. What further optimization is required in my code??
https://www.spoj.pl/problems/FACVSPOW/
/*FACVSPOW*/
#includestdio.h
#includecmath
using
follow what Akash said..!!
in case you still need help just go through http://ideone.com/al0U0 in
devcpp..!!
On Sat, May 28, 2011 at 2:34 PM, Aakash Johari aakashj@gmail.comwrote:
Precompute the values. and then do queries.
On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma
@sukhmeetyour code is having runtime error !!
On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh sukhmeet2...@gmail.comwrote:
follow what Akash said..!!
in case you still need help just go through http://ideone.com/al0U0 in
devcpp..!!
On Sat, May 28, 2011 at 2:34 PM, Aakash Johari
don't see the online compiler.. it doesn't allow such a large array.. try on
LINUX..
this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ
On Sat, May 28, 2011 at 5:26 PM, Logic King crazy.logic.k...@gmail.comwrote:
@sukhmeetyour code is having runtime error !!
On Sat, May 28,
thanks all :)
On Sat, May 28, 2011 at 8:08 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
don't see the online compiler.. it doesn't allow such a large array.. try
on LINUX..
this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ
On Sat, May 28, 2011 at 5:26 PM, Logic King
Hi all. Can some one provide a good C editor.. preferable GUI one, that
works on windows 7.
I'm good with Java, but. now would like to get some hands on C, C++
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
@tec: the sequence should be like (0,1),(1,1),(1,2),(2,3),(3,5),(5,8)... or
m i wrong?
On Mon, May 23, 2011 at 11:08 AM, Aakash Johari aakashj@gmail.comwrote:
Matrix exponentiation can help i think
On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma
akshatasharm...@gmail.com wrote:
It
@akshata,
The (1,1) would be a special case.
for give N=1, but again for N=1, (2,1) also satisfies well.
And the series from then is constructed on the (1,0), (2,1), (3,2) So and
so..
Also if you see in the original problem statement, they mentioned a=b, but
not ab..
this is for the special
There is also another special case.. where N=0, in this case.. its (0,0)
-- 0+0 = 0
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email
@sravanreddy001
suppose u have to calulate A^n u can calculate in O(d^3*log(n));
d is dimesion of matrixl
while (n)
{
if (n1) mul(ans, A, d);
mul(A, A, d);
n =1;
}
--
Anshuman Mishra
IIIT Allahabad
-
@sravanreddy001
by matrix exponential method, we can calculate the nth fibonacci number in
logarithmic time.
On Mon, May 23, 2011 at 7:39 PM, anshu mishra anshumishra6...@gmail.comwrote:
@sravanreddy001
suppose u have to calulate A^n u can calculate in O(d^3*log(n));
d is dimesion of matrixl
@akshata, sravanreddy: yes, for more info regarding matrix expo. you can go
through http://zobayer.blogspot.com/2010/11/matrix-exponentiation.html
On Mon, May 23, 2011 at 7:28 AM, Akshata Sharma
akshatasharm...@gmail.comwrote:
@sravanreddy001
by matrix exponential method, we can calculate the
we can use the following formula to calculate the nth fibonacci no. in O(log
n) time : fib(n)=round((pow(phi,n))/sqrt(5) + 1/2) where phi=(1+sqrt(5))/2;
And by taking care of the special cases and by using the fact that the problem
is just to find the (N+3)th fibonacci number for given N, we
Hey,
Can anyone tell how to solve this problem in Spoj ? I went through
some material but there all they were discussing was on complexity and
not on actual number of iterations.
http://www.spoj.pl/problems/MAIN74/
Thanks.
--
You received this message because you are subscribed to the Google
Try thinking backwards.
(0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...
2011/5/22 shady sinv...@gmail.com:
Hey,
Can anyone tell how to solve this problem in Spoj ? I went through
some material but there all they were discussing was on complexity and
not on actual number of iterations.
It appers that the problem is just to find the (N+3)th fibonacci number for
given N. Since N is very large, how to find nth fibonaci number for such a
large n??
On Mon, May 23, 2011 at 7:51 AM, tec technic@gmail.com wrote:
Try thinking backwards.
(0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...
Matrix exponentiation can help i think
On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
It appers that the problem is just to find the (N+3)th fibonacci number for
given N. Since N is very large, how to find nth fibonaci number for such a
large n??
On Mon,
20 matches
Mail list logo