Re: [algogeeks] spoj problem EASYMATH

2012-09-29 Thread Wladimir Tavares
Using KISS :) http://en.wikipedia.org/wiki/KISS_principle Ps: is not an offensive message Wladimir Araujo Tavares *Federal University of Ceará Homepage | Maratona| * On Fri, Sep

Re: [algogeeks] spoj problem EASYMATH

2012-09-28 Thread icy`
why not just brute force this? one little array contains [a, (a+d), (a+2d), (a+3d), (a+4d) ], which is then filtered so that none of those are multiples of another. Then set a count variable to m-n+1. Check all numbers in range against your little array, decrementing count and breaking out if a

Re: [algogeeks] spoj problem EASYMATH

2012-09-28 Thread atul anand
@Wladimir : you have to use formula given in below link http://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle On Fri, Sep 28, 2012 at 12:26 AM, Wladimir Tavares wrote: > what happens when a = 3, d = 5 > a, a + d, d +2, a +3 d = 3,8,13,18? > > Wladimir Araujo Tavares > *Federal

Re: [algogeeks] spoj problem EASYMATH

2012-09-27 Thread Wladimir Tavares
what happens when a = 3, d = 5 a, a + d, d +2, a +3 d = 3,8,13,18? Wladimir Araujo Tavares *Federal University of Ceará Homepage | Maratona| * On Thu, Sep 27, 2012 at 8:57 AM, atul

Re: [algogeeks] spoj problem EASYMATH

2012-09-27 Thread atul anand
@ashish : here is the generalized equation http://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle note : you need to take LCM of a,a+d,a+2d etc etcwhenever you are dividing to find count On Thu, Sep 27, 2012 at 2:55 AM, ashish pant wrote: > thanks for your reply.. actual

Re: [algogeeks] spoj problem EASYMATH

2012-09-27 Thread ashish pant
thanks for your reply.. actually i was thinking the same thing.. but I am facing problems in finding the unique multiples of a+3d and a+4d as applying inclusion exclusion principle in this way is getting too difficult due to large no of factors to be added and subtracted.. is der any other approac

Re: [algogeeks] spoj problem EASYMATH

2012-09-26 Thread atul anand
EXAMPLE 1) 1 10 2 2 a,d=2 a,a+d,a+2d,a+3d,a+4d are all multiple of 2 , so basically you need to count elements which are multiple of 2 and then subtract from the 1-10 range(inclusive) number of elements multiple of of 2 = (m/2) = 10/2 = 5 range = ( m - n) + 1 = 10 number of elements not multipl

Re: [algogeeks] spoj problem EASYMATH

2012-09-26 Thread gaurav yadav
an idea of the approach would be enough.. plz help.. -- 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 to algogeeks+unsubscr...@googleg

[algogeeks] spoj problem EASYMATH

2012-09-25 Thread gaurav yadav
help needed in spoj problem EASYMATH .. i thought about inclusion exclusion principle but unable to get to a solution.. plz help.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on

Re: [algogeeks] spoj problem EASYMATH

2012-06-24 Thread shady
dont post codes, ask whether your algorithm is correct or not. On Sun, Jun 24, 2012 at 8:29 PM, Hassan Monfared wrote: > use " return (a/gcd(a,b)*b instead " > > > On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh > wrote: > >> please suggest something : >> >> Problem : >> http://www.spoj.pl/probl

Re: [algogeeks] spoj problem EASYMATH

2012-06-24 Thread Hassan Monfared
use " return (a/gcd(a,b)*b instead " On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh wrote: > please suggest something : > > Problem : > http://www.spoj.pl/problems/EASYMATH/ > > C++ code : > http://ideone.com/r2OSb > was getting wrong ans due to over flow i think in LCM() for big prime's i > gue

[algogeeks] spoj problem EASYMATH

2012-06-24 Thread Sourabh Singh
please suggest something : Problem : http://www.spoj.pl/problems/EASYMATH/ C++ code : http://ideone.com/r2OSb was getting wrong ans due to over flow i think in LCM() for big prime's i guess. thin tried in python . Now getting NZEC for python code which mean's high level or recurrsion some where

Re: [algogeeks] SPOJ problem :STAMPS

2012-06-22 Thread Pradip Singh
use if(sum wrote: > @MAYANK your output format is wrong.use printf("\nScenario #%d:\n",(i+1)); > and > if(sum On Thu, Jun 21, 2012 at 12:34 PM, Mayank Singh < > singh13490may...@gmail.com> wrote: > >> here is my code >> /*#include >> #include >> >> int main() >> { >> int cand,sum; >> in

Re: [algogeeks] SPOJ problem :STAMPS

2012-06-22 Thread Pradip Singh
@MAYANK your output format is wrong.use printf("\nScenario #%d:\n",(i+1)); and if(sum wrote: > here is my code > /*#include > #include > > int main() > { > int cand,sum; > int T,N,i,j,temp[10]; > scanf("%d",&T); > > sum = 0; > for(i=0;i { > scanf("%d",&N); >

Re: [algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread amrit harry
@Mayank coding style not seems gud.. try this... int main() { int testCases; scanf("%d",&testCases); while(testCases-->0) { //perform ur logic //print output for each test case here instead of storing it into an array. } } return 0; } On Thu, Jun 21, 2012 at 10:35 P

Re: [algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread Mayank Singh
thanx it worked -- 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 to algogeeks+unsubscr...@googlegroups.com. For more options, visi

Re: [algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread romil bansal
Initialize sum as zero for all test cases ie inside 1st for loop. On Jun 21, 2012 5:22 PM, "Mayank Singh" wrote: > here is my code : > > #include > #include > > int main() > { > long long cand,sum; > int T,N,i,j,*temp; > scanf("%d",&T); > temp= (int*)calloc(T, sizeof( int)); >

[algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread Mayank Singh
here is my code : #include #include int main() { long long cand,sum; int T,N,i,j,*temp; scanf("%d",&T); temp= (int*)calloc(T, sizeof( int)); sum = 0; for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] SPOJ problem : CANDY

2012-06-21 Thread Bhavesh agrawal
i think you should try to give output for each test case rather to use any temp array -- 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

Re: [algogeeks] SPOJ problem : CANDY

2012-06-21 Thread Mayank Singh
my code is running perfectly well but giving WA in spoj.. #include #include int main() { int cand,sum; int T,N,i,j,temp[10]; scanf("%d",&T); sum = 0; for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] SPOJ problem : CANDY

2012-06-21 Thread Bhavesh agrawal
in this prob also for i=0, i to k read cand rem=(rem+cand)%k if (rem) then no else yes -- 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

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Mayank Singh
oh i am really sorry the problem is CANDY III can you help me regarding that once again sorry -- 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 th

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Krishnan
@mayank: For each testcase sum is not zero make "sum=0" inside the for loop -- 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 to algog

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Bhavesh agrawal
here is my code u can check that.. http://ideone.com/Gii1d -- 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 to algogeeks+unsubscr...@g

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Mayank Singh
still getting the WA . is there any test case i am getting wrong? -- 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 to algogeek

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Bhavesh agrawal
long long not require in this que . try it again.. -- 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 to algogeeks+unsubscr...@googlegr

[algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Mayank Singh
i am using long long but still getting WA. here's my code #include #include int main() { long long cand,sum; int T,N,i,j,temp[10]; scanf("%d",&T); sum = 0; for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

[algogeeks] spoj problem : POKER

2012-06-18 Thread Mayank Singh
here is my code: #include #include #include int main() { int t,i,j,k1,k2,ans[40],sum,sum1; char str[40][20],str1[6],str2[6]; scanf("%d",&t); for(i=0;i<=t;i++) { gets(str[i]); } for(i=1;i<=t;i++) { for(j=1,k1=0;j<15,k1<5;j=j+3,k1++) {

Re: [algogeeks] spoj problem : NSTEPS

2012-06-17 Thread Mayank Singh
thanx it worked... -- 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 to algogeeks+unsubscr...@googlegroups.com. For more options, v

Re: [algogeeks] spoj problem : NSTEPS

2012-06-17 Thread Pranjal Patil
array size not sufficient coz n can be greater than 1 try x[100], y[100] :-) On Sun, Jun 17, 2012 at 9:32 PM, Mayank Singh wrote: > here is my code for the above problem: > > #include > #include > > int main() > { >     int i,x[1],y[1],val; >     long n; >     scanf("%d",&n);

[algogeeks] spoj problem : NSTEPS

2012-06-17 Thread Mayank Singh
here is my code for the above problem: #include #include int main() { int i,x[1],y[1],val; long n; scanf("%d",&n); for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

[algogeeks] spoj problem

2012-06-12 Thread gaurav yadav
plz nyone explain how to approach this problem.. http://www.spoj.pl/problems/XORROUND/ -- 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

Re: [algogeeks] spoj problem

2012-05-13 Thread Krishnan
@ashish pant We must compute all the queries in O(n)+O(k). We must have array like counting array. It is not my logic but my friend told about this logic -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to a

[algogeeks] spoj problem

2012-05-13 Thread ashish pant
please help me out with this problem http://www.spoj.pl/problems/HAYBALE/ -- 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 to alg

Re: [algogeeks] spoj problem

2012-01-23 Thread Anil Arya
No one is going to check my your code Don't submit my code directly to spoj ,,,Learn from it...and then make your own code.. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;

[algogeeks] spoj problem

2012-01-23 Thread D!leep Gupta
guys plz help... http://www.spoj.pl/problems/BUGLIFE/ i m getting wrong ans can any one give me the test case on which my code giving wrong... i m unable to find out #include#define MAX 2500int front=-1;int rear=-1;int q[MAX]; void addq(int n) { q[++rear]=n; }int

Re: [algogeeks] spoj problem

2011-11-14 Thread sunny agrawal
one solution is use BFS On Mon, Nov 14, 2011 at 8:52 PM, Anshul AGARWAL wrote: > i m try to increase current floor c by push up button until it equal or > greater than  "g"  and increase co-responding push "p".when my current > floor is greater than "g".i push down button once and increase "p " b

Re: [algogeeks] spoj problem

2011-11-14 Thread Anshul AGARWAL
i m try to increase current floor c by push up button until it equal or greater than "g" and increase co-responding push "p".when my current floor is greater than "g".i push down button once and increase "p " by 1. repeat this loop until i get c==g. *Anshul Agarwal Nit Allahabad Computer Science*

Re: [algogeeks] spoj problem

2011-11-14 Thread shady
what;s your algorithm ? On Mon, Nov 14, 2011 at 7:57 PM, Anshul AGARWAL wrote: > problem is http://www.spoj.pl/problems/ELEVTRBL/ > and my solution is give wrong answer on spoj . Plz help me to find in > which case my solution give wrong answer. > > > * > #include > ** > #include > using namespac

[algogeeks] spoj problem

2011-11-14 Thread Anshul AGARWAL
problem is http://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on spoj . Plz help me to find in which case my solution give wrong answer. * #include ** #include using namespace std; int main() { long long int f,s,u,d,g,c,p; scanf("%lld%lld%lld%lld%lld",&f,&s,&g,&u,

[algogeeks] SPOJ problem

2011-09-17 Thread amrit harry
http://www.spoj.pl/problems/POUR1/ hw the 2nd given test is correct. 2 3 4 first we fill 3 littre jar with water and put into 4 littre jar den again fill 3 littre and pour it in 2 littre remaining water in jar is 1 littre put it into 4 littre and we can measure 4 littre of water den why answer is

Re: [algogeeks] spoj problem double helix

2011-08-30 Thread Amol Sharma
check this test case i/p 2 1 5 1 9 0 o/p 9 your code gives 12... -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad

[algogeeks] spoj problem double helix

2011-08-30 Thread saurabh singh
I am repeatedly getting Wrong answer for this problem.I am not sure where I am going wrong. I am finding the intersection point by the normal algorithm(Maintaining two pointers and moving forward the smaller one and I am then concating the elements into their sum about the intersection point)

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-29 Thread UTKARSH SRIVASTAV
hi see the logic all the factors of a number are evenly distributed about it's square root for e.g 100 1 X 100 2 X 50 4 X 25 5 X 20 10 X 10 AFTER THIS THE PAIRS REPEATE THEMSELVES BUT IN OPPOSITE ORDER 20 X 5 25 X 4 50 X 2 100 X 1 SO IF YOU MAKE YOUR LOOP GO TO SQRT(N) AND IF YOU FIND A FACTOR OF

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-28 Thread kartik sachan
it can be simply done in O(sqrt(n)) -- 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 to algogeeks+unsubscr...@googlegroups

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
Yeah, sorry I was giving a hint for DIVSUM2, which is a much harder version of DIVSUM. You are checking all numbers less than n for divisibility. This is O(n). Figure out how can you find the set of divisors using primes. This can be done in O(2^d), if there are d prime divisors. On Sat, Aug 27

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
http://lmgtfy.com/?q=pollard%27s+rho+algorithm On Sat, Aug 27, 2011 at 11:05 PM, Rahul Verma wrote: > @gaurav Thanks dear > Could you please explain the algorithm. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this disc

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread saurabh modi
you could use seiving.its fast.its practical. -- 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 to algogeeks+unsubscr...@googlegroups.c

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Rahul Verma
@gaurav Thanks dear Could you please explain the algorithm. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/TNa8UygkzGkJ. To post to this group, send e

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
You might want to check out Pollard Rho algorithm. On Sat, Aug 27, 2011 at 9:57 PM, Rahul Verma wrote: > I am trying to submit solution for the SPOJ DIVSUM problem, but it returns > the time limit exceeded. Code submitted by me is below: > > #include > #include > using namespace std; > int prop

[algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Rahul Verma
I am trying to submit solution for the SPOJ DIVSUMproblem, but it returns the *time limit exceeded*. Code submitted by me is below: #include #include using namespace std; int proper_divisor(int number); int main() { int test,i,number; cin>>test;

[algogeeks] SPOJ Problem

2011-08-25 Thread Rahul Verma
Hi everybody, I am trying to solve the below mentioned SPOJ problem. I am not getting that how it returns *11 56 *in 3rd test. SPOJ Problem: http://www.spoj.pl/problems/CMPLS/ Sincerely, Rahul Verma -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"

Re: [algogeeks] SPOJ Problem Evaluating Expression

2011-07-23 Thread SAMM
It forms a pattern for each combination i solved it tht way in spoj. On 7/24/11, shady wrote: > Does anyone know how to simplify the expression for this problem ? > https://www.spoj.pl/problems/EXFOR/ To get AC for this problem we can always > solve the expression, which is bruteforce, any other

[algogeeks] SPOJ Problem Evaluating Expression

2011-07-23 Thread shady
Does anyone know how to simplify the expression for this problem ? https://www.spoj.pl/problems/EXFOR/ To get AC for this problem we can always solve the expression, which is bruteforce, any other better way ? Mathematician's way ? -- You received this message because you are subscribed to the Go

[algogeeks] spoj problem TAILS

2011-07-04 Thread cegprakash
I'm trying to solve this problem: www.spoj.pl/problems/TAILS I tried of eliminating 1's from left to right and from right to left and printed the minimum among them. I got WA. Any other ideas to proceed this problem? -- You received this message because you are subscribed to the Google Groups

[algogeeks] SPOJ Problem DP

2011-07-01 Thread shady
Hi, I am solving this http://www.spoj.pl/problems/DP/ problem using Djikstra's algorithm. What is the dynamic programming solution to this ? PS : Don't post the code, but the states of dp. Thanks. Shady -- You received this message because you are subscribed to the Google Groups "Algorithm Ge

Re: [algogeeks] spoj problem chairs

2011-06-19 Thread abc abc
@above Better you ask it on spoj forum On Sun, Jun 19, 2011 at 7:27 PM, saurabh singh wrote: > I am getting WA for this problem.I dont know whether its case of overflow > or I have come up with a wrong formula, > https://www.spoj.pl/problems/CHAIR/ > I am coding in python so I dont think there

[algogeeks] spoj problem chairs

2011-06-19 Thread saurabh singh
I am getting WA for this problem.I dont know whether its case of overflow or I have come up with a wrong formula, https://www.spoj.pl/problems/CHAIR/ I am coding in python so I dont think there is probblem of overflow. def f(n): if n<0: return 0 if n==0: return 1 i=n

Re: [algogeeks] Spoj Problem Help

2011-06-05 Thread tec
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:

Re: [algogeeks] spoj problem acode

2011-06-01 Thread keyan karthi
oops.. :P that an "if" didnt notice tat :D On Wed, Jun 1, 2011 at 8:34 PM, keyan karthi wrote: > even if the left over string length is >1 so that the recursion can be > fun(s,current_position-2), u still have the option for choosing a single > character... do u get it?? > thats where u go wron

Re: [algogeeks] spoj problem acode

2011-06-01 Thread keyan karthi
even if the left over string length is >1 so that the recursion can be fun(s,current_position-2), u still have the option for choosing a single character... do u get it?? thats where u go wrong... :) the rec call should be "return fun(cur_length-1)+fun(cur_len-2)" ... On Wed, Jun 1, 2011 at 3:34

Re: [algogeeks] spoj problem acode

2011-06-01 Thread arun kumar
hey me getting wrong ans..can anyone pls help me out here s my code #include #include #include #include using namespace std; unsigned long long a[5001]={0}; unsigned long long fun(string &s,int n) { if(n==0) return 1; if(a[n]) return a[n]; int c=0,d=0; c=s[n]-'0'; d=s[n-1]-'0';

[algogeeks] spoj problem acode

2011-06-01 Thread pacific :-)
Link : https://www.spoj.pl/problems/ACODE/ 25114 BEAN’, ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ ‘BEKD’. How many different decodings?” My soln , but i get TLE.Please help. #include #include #include using namespace std; char * head; int result[5001]; int count(char * a ,int size) { if(result[a-head]

Re: [algogeeks] SPOJ Problem Help

2011-05-30 Thread oldman
Code::Blocks On Sun, May 29, 2011 at 1:59 AM, Akash Mukherjee wrote: > devcpp > > > On Sat, May 28, 2011 at 11:17 PM, sravanreddy001 > wrote: > >> 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

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Akash Mukherjee
devcpp On Sat, May 28, 2011 at 11:17 PM, sravanreddy001 wrote: > 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

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Aakash Johari
Install Cygwin and Vim Editor for Windows This is what I use. On Sat, May 28, 2011 at 10:47 AM, sravanreddy001 wrote: > 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++ > > -- > Yo

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sravanreddy001
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 emai

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Akshata Sharma
thanks all :) On Sat, May 28, 2011 at 8:08 PM, sukhmeet singh wrote: > 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 wrote: > >> @sukhmeet..

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
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 wrote: > @sukhmeetyour code is having runtime error !! > > > On Sat, May 28, 2011 at 4:48 AM, sukhme

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Logic King
@sukhmeetyour code is having runtime error !! On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh wrote: > 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 wrote: > >> Precompute th

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
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 wrote: > Precompute the values. and then do queries. > > > On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma > wrote: > >> My code gives TLE.

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Aakash Johari
Precompute the values. and then do queries. On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma wrote: > My code gives TLE. What further optimization is required in my code?? > https://www.spoj.pl/problems/FACVSPOW/ > > > /*FACVSPOW*/ > #include > #include > > using namespace std; > > int calc(long n

[algogeeks] SPOJ Problem Help

2011-05-28 Thread Akshata Sharma
My code gives TLE. What further optimization is required in my code?? https://www.spoj.pl/problems/FACVSPOW/ /*FACVSPOW*/ #include #include 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() { long t; scanf("

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread ankit sambyal
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 can

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Aakash Johari
@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 wrote: > @sravanreddy001 > by matrix exponential method, we can calculate the nth fibonacci number in

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Akshata Sharma
@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 wrote: > @sravanreddy001 > suppose u have to calulate A^n u can calculate in O(d^3*log(n)); > d is dimesion of matrixl > while (n) > {

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread anshu mishra
@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 (n&1) mul(ans, A, d); mul(A, A, d); n >>=1; } -- Anshuman Mishra IIIT Allahabad - anshumishra6

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread sravanreddy001
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 ema

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread sravanreddy001
@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 a>b.. this is for the special c

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Akshata Sharma
@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 wrote: > Matrix exponentiation can help i think > > On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma < > akshatasharm...@gmail.com> wrote: > >> It appers that the

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread Aakash Johari
Matrix exponentiation can help i think On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma wrote: > 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

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread Akshata Sharma
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 wrote: > Try thinking backwards. > (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),... > > 2011/5/22 shady :

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread tec
Try thinking backwards. (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),... 2011/5/22 shady : > 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/problem

[algogeeks] Spoj Problem Help

2011-05-22 Thread shady
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 Gro

[algogeeks] SPOJ problem: HASHIT

2011-05-20 Thread ankit sambyal
Hey guys , I am getting wrong answer in : http://www.spoj.pl/problems/HASHIT/. Somebdy plz check it out or provide some test cases. This code works fine with the test cases provided and even my own test cases. The following is my code: #include #include int main() { int num_tcases,num_ops,

[algogeeks] SPOJ Problem : PALIN

2011-03-28 Thread ankit sambyal
I m getting WA in this question though all the test cases are giving correct output. Link to the problem : https://www.spoj.pl/problems/PALIN/ Can anybdy check out my code . The following is my code : #include #include int compare(char s[], char t[]) { //only check second half int mid

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread bharath kannan
i already mentioned the link where i got this approach.. //from spoj forum I have tried this problem with the following approach:- 1. any expression can be expressed as ))...)+a_correct_expression+((...( 2.at each node i am storing 1.no_of ')' at start and 2.no_of '(' at end of expression that the

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread sukhmeet singh
Bharath can u tell me how u came with the combine function ??? I can't understand the logic behind it ... do reply On Wed, Mar 16, 2011 at 10:24 PM, Bharath 2009503507 CSE < bharathgo...@gmail.com> wrote: > i am new to segment trees..i tried this problem in spoj.. > http://www.spoj.pl/problems/BR

Re: [algogeeks] SPOJ problem

2011-03-25 Thread saurabh singh
I am very sorry but i dont think i got your point.You suggesting interpolation or some other technique? Kindly suggest some reference for good precomputation techniques.. Thanks in advance -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you a

Re: [algogeeks] SPOJ problem

2011-03-25 Thread saurabh singh
I am very sorry but i dont think i got your point.You suggesting interpolation? Kindly suggest some reference for good precomputation techniques.. Thanks in advance -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, se

Re: [algogeeks] SPOJ problem

2011-03-25 Thread sukhmeet singh
try using precomputation in a better way ...this got me AC.. rest is just binary search function ...!!! On Thu, Mar 24, 2011 at 9:06 PM, .bashrc wrote: > Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ > I am getting TLE using binary search. > Thanks in advance > > -- > You

[algogeeks] SPOJ problem

2011-03-24 Thread .bashrc
Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ I am getting TLE using binary search. Thanks in advance -- 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

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
Thanks 2 all On Mon, Mar 21, 2011 at 9:19 AM, Anurag atri wrote: > @krishna - yeah as Bharath said that case should give NO , anyways you got > it now :) > > > On Mon, Mar 21, 2011 at 5:50 AM, murthy.krishn...@gmail.com < > murthy.krishn...@gmail.com> wrote: > >> @bharath yaa now I got the ques,

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread Anurag atri
@krishna - yeah as Bharath said that case should give NO , anyways you got it now :) On Mon, Mar 21, 2011 at 5:50 AM, murthy.krishn...@gmail.com < murthy.krishn...@gmail.com> wrote: > @bharath yaa now I got the ques, thanx :-) > > > On Mon, Mar 21, 2011 at 4:47 AM, bharath kannan wrote: > >> @mur

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
@bharath yaa now I got the ques, thanx :-) On Mon, Mar 21, 2011 at 4:47 AM, bharath kannan wrote: > @murthy:no..the op must be NOits not a valid expression..read the two > conditions for a valid expression.. > > On Sun, Mar 20, 2011 at 8:23 PM, murthy.krishn...@gmail.com < > murthy.krishn...@

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread bharath kannan
@murthy:no..the op must be NOits not a valid expression..read the two conditions for a valid expression.. On Sun, Mar 20, 2011 at 8:23 PM, murthy.krishn...@gmail.com < murthy.krishn...@gmail.com> wrote: > @anurag accor to me the output must be YES, correct me if I am wrong > > > On Sun, Mar 2

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
@anurag accor to me the output must be YES, correct me if I am wrong On Sun, Mar 20, 2011 at 10:40 AM, bharath kannan wrote: > i thot tat i had some mistake in my code and typed it all over again.. > finally i noticed this :) > > > > On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil wrote: > >> Hey.

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil wrote: > Hey.. > I also got into same trouble today... > I submitted it 6 times..then got bored and de moralised cause i cudnt find > flaw in code... >

Re: [algogeeks] SPOJ problem- TRICOUNT

2011-03-19 Thread sukhmeet singh
may be u can try to find a more general formula for the series..which just depends on 'n'... On Sat, Mar 19, 2011 at 11:48 PM, cegprakash wrote: > Here is my code for TRICOUNT problem > > //http://www.spoj.pl/problems/TRICOUNT/ > //cegprak...@gmail.com > > #include > #include > using namespace s

[algogeeks] SPOJ problem- TRICOUNT

2011-03-19 Thread cegprakash
Here is my code for TRICOUNT problem //http://www.spoj.pl/problems/TRICOUNT/ //cegprak...@gmail.com #include #include using namespace std; unsigned long long start,end,arr[101],arr2[101]; //number of triangles facing upwards=arr //number of triangles facing downwards=arr2 int main(){

  1   2   >