[algogeeks] SPoj maximum sum subseuence

2011-03-12 Thread Ankur Khurana
https://www.spoj.pl/problems/MAXSUMSQ/ Hi in above problem , i am getting TLE but according to given contraints , i think my code is good enough to run. Can any body help me here #include #include #include #include #include #include #include #include #include #define VI vector typede

[algogeeks] Bhavesh agrawal wants to chat

2011-03-12 Thread Bhavesh agrawal
--- Bhavesh agrawal wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-b4f0875ca2-29d66a53f9-Tt0nFfpQ80JaH-2cWOceg6RZIxQ You'l

[algogeeks] Re: Interesting & Toughest Problem On Telephone P&C ..

2011-03-12 Thread priyank desai
You cn also use modified BFS with mappings from numbers to its corresponding paths and print the paths from the root. On Mar 12, 7:45 am, xyz69 wrote: > Number 1, doesn't represent any letter. > > pseudocode, (numbers is array of numbers, currentString is currently > composed string to show) > >

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
https://www.spoj.pl/problems/STREETR/ On 3/12/11, kumar anurag wrote: > which probem ? pls gve the link > On Sat, Mar 12, 2011 at 8:27 PM, Akshata Sharma > wrote: > >> yeah I too got AC. The way I was calculating gcd was not efficient. :) >> >> On 3/12/11, Logic King wrote: >> > Here is my s

Re: [algogeeks] spoj problem

2011-03-12 Thread kumar anurag
which probem ? pls gve the link On Sat, Mar 12, 2011 at 8:27 PM, Akshata Sharma wrote: > yeah I too got AC. The way I was calculating gcd was not efficient. :) > > On 3/12/11, Logic King wrote: > > Here is my solution.i got it AC > > > > #include > > int gcd(int a, int b) > > { int temp

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
yeah I too got AC. The way I was calculating gcd was not efficient. :) On 3/12/11, Logic King wrote: > Here is my solution.i got it AC > > #include > int gcd(int a, int b) > { int temp; >while(b) >{ >temp = a % b; >a = b; >b = temp; >

Re: [algogeeks] spoj problem

2011-03-12 Thread Logic King
Here is my solution.i got it AC #include int gcd(int a, int b) { int temp; while(b) { temp = a % b; a = b; b = temp; } return(a); } int main() { int n,i,min,ans=0; scanf("%d",&n); int arr[n],ard[n]; ard[0]=1; if(n>0) sc

Re: [algogeeks] spoj problem

2011-03-12 Thread Balaji Ramani
Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor wrote: > > > @balaji:i hve got ac with gcd method but the time is 0.32 sec > best soln is 0.03 > how is that achievable? > -- > Satyam Kapoor > B.Tech 2nd year > Computer Science And Enginee

Re: [algogeeks] spoj problem

2011-03-12 Thread Satyam Kapoor
@balaji:i hve got ac with gcd method but the time is 0.32 sec best soln is 0.03 how is that achievable? -- Satyam Kapoor B.Tech 2nd year Computer Science And Engineering M.N.N.I.T ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

Re: [algogeeks] spoj problem

2011-03-12 Thread Balaji Ramani
@Akshata, Satyam: I think that might be because the way you are using to calculate gcd is inefficient. I got AC. I used the following technique to calculate gcd: long long int gcd(long long int a, long long int b){ long long int rem = a%b; if(rem == 0) return b; return gcd(b,rem); } long

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
@Balaji: that WA was due to using int in place of long long in loop. But still, this is giving TLE. On Sat, Mar 12, 2011 at 7:07 PM, Akshata Sharma wrote: > sorry, @satyam: then what is the 'best' solution for this? :) > > > On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma > wrote: > >> @Ankur: th

Re: [algogeeks] spoj problem

2011-03-12 Thread Satyam Kapoor
@akshata:i did this one by hcf method but it took too much time... -- Satyam Kapoor B.Tech 2nd year Computer Science And Engineering M.N.N.I.T ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to al

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma wrote: > @Ankur: then what is the 'best' solution for this? :) > @Balaji: i tried implementing but I dont know which case it fails?? getting > WA now!! > Here is the code: > > #include >

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
@Ankur: then what is the 'best' solution for this? :) @Balaji: i tried implementing but I dont know which case it fails?? getting WA now!! Here is the code: #include int main() { long n,gcd=1; scanf("%d",&n); long long a[n],b[n],cnt=0,sum=0; long long min=9; scanf("%lld",&a[0]); fo

[algogeeks] Re: Interesting & Toughest Problem On Telephone P&C ..

2011-03-12 Thread xyz69
Number 1, doesn't represent any letter. pseudocode, (numbers is array of numbers, currentString is currently composed string to show) function printChar(numbers, currentString){ for (every letter coded as numbers[0]){ if (numbers.lenght>1){ printChar(numbers[1:], currentString+letter)

Re: [algogeeks] spoj problem

2011-03-12 Thread Satyam Kapoor
this is gud but not the best soln. -- Satyam Kapoor B.Tech 2nd year Computer Science And Engineering M.N.N.I.T ALLAHABAD -- 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 uns

Re: [algogeeks] spoj problem

2011-03-12 Thread Balaji Ramani
Find the gcd of n-1 differences ( a[1]..a[n-1] with a[0] ) ans = (a[n-1] - a[0])/gcd - n + 1 Thanks, Balaji. On Sat, Mar 12, 2011 at 2:00 PM, Akshata Sharma wrote: > Any faster way to solve this problem?? > > On 3/12/11, Balaji Ramani wrote: > > Yes, the correct answer is 0. > > > > "if(flag =

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
Any faster way to solve this problem?? On 3/12/11, Balaji Ramani wrote: > Yes, the correct answer is 0. > > "if(flag ==0 || ans ==0)" i think can be changed to "if(flag ==0)" alone. > > Thanks, > Balaji. > > On Sat, Mar 12, 2011 at 10:16 AM, Satyam Kapoor > wrote: > >> is case main answer 0 hona