Re: [algogeeks] spoj problem
Any faster way to solve this problem?? On 3/12/11, Balaji Ramani rbalaji.psgt...@gmail.com 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 satyamkapoo...@gmail.comwrote: is case main answer 0 hona chahiye. -- 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
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 akshatasharm...@gmail.comwrote: Any faster way to solve this problem?? On 3/12/11, Balaji Ramani rbalaji.psgt...@gmail.com 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 satyamkapoo...@gmail.comwrote: is case main answer 0 hona chahiye. -- 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Interesting Toughest Problem On Telephone PC ..
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.lenght1){ printChar(numbers[1:], currentString+letter) } else { print(currentString+letter) } } } On 11 Mar, 16:45, bittu shashank7andr...@gmail.com wrote: Hy Guys I want to do . for any phone number .. the program should print out all the possible strings it represents. For eg.) 2 in the number can be replaced by 'a' or 'b' or 'c', 3 by 'd' 'e' 'f' etc. In this way how many possible permutations can be formed from a given phone number. I don't want anyone to write code for it ... a good algorithm or psuedocode would be great. I am talking about old small phone where a single digit corresponds to 3charcter from digit 2 to 8 and digit 9 has 4 character w x y z ..Hope everyone got my points what i wants well i tried my solution but thats become so complex so now even i am facing to understand that so will anybody try this interesting question . more clearly for digit o/p is AD AE AF BD BE BF CD CE CF Now You Can Imegin what will be o/p for 9740852296 or any 10 digit number Think as much as you can but finally solution matters .. Thanks Regards Shashank Mani -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
@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: #includestdio.h 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]); for(long i=1;in;i++) { scanf(%lld,a[i]); b[i-1]=a[i]-a[0]; if(minb[i-1]) min=b[i-1]; } for(int k=min;k0;k--) { cnt=0; for(int i=0;in-1;i++) { if(b[i]%k==0) cnt++; } if(cnt==n-1) { gcd=k; break; } } sum=((a[n-1]-a[0])/gcd)-n+1; printf(%lld\n,sum); return 0; } On Sat, Mar 12, 2011 at 2:38 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma akshatasharm...@gmail.comwrote: @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: #includestdio.h 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]); for(long i=1;in;i++) { scanf(%lld,a[i]); b[i-1]=a[i]-a[0]; if(minb[i-1]) min=b[i-1]; } for(int k=min;k0;k--) { cnt=0; for(int i=0;in-1;i++) { if(b[i]%k==0) cnt++; } if(cnt==n-1) { gcd=k; break; } } sum=((a[n-1]-a[0])/gcd)-n+1; printf(%lld\n,sum); return 0; } On Sat, Mar 12, 2011 at 2:38 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
@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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
@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 akshatasharm...@gmail.comwrote: sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma akshatasharm...@gmail.com 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: #includestdio.h 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]); for(long i=1;in;i++) { scanf(%lld,a[i]); b[i-1]=a[i]-a[0]; if(minb[i-1]) min=b[i-1]; } for(int k=min;k0;k--) { cnt=0; for(int i=0;in-1;i++) { if(b[i]%k==0) cnt++; } if(cnt==n-1) { gcd=k; break; } } sum=((a[n-1]-a[0])/gcd)-n+1; printf(%lld\n,sum); return 0; } On Sat, Mar 12, 2011 at 2:38 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
@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 long int gcdvar = a[1]-a[0]; for(i=2;in;i++) { gcdvar = gcd(a[i]-a[0],gcdvar); } Thanks, Balaji. On Sat, Mar 12, 2011 at 7:16 PM, Akshata Sharma akshatasharm...@gmail.comwrote: @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 akshatasharm...@gmail.com wrote: sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma akshatasharm...@gmail.com 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: #includestdio.h 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]); for(long i=1;in;i++) { scanf(%lld,a[i]); b[i-1]=a[i]-a[0]; if(minb[i-1]) min=b[i-1]; } for(int k=min;k0;k--) { cnt=0; for(int i=0;in-1;i++) { if(b[i]%k==0) cnt++; } if(cnt==n-1) { gcd=k; break; } } sum=((a[n-1]-a[0])/gcd)-n+1; printf(%lld\n,sum); return 0; } On Sat, Mar 12, 2011 at 2:38 PM, Satyam Kapoor satyamkapoo...@gmail.com wrote: 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
@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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
Here is my solution.i got it AC #includestdio.h 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(n0) scanf(%d,arr[0]); for(i=1;in;i++) { scanf(%d,arr[i]); ard[i]=arr[i]-arr[i-1]; if(i==1) min=ard[i]; else min=gcd(min,ard[i]); } for(i=1;in;i++) { ans+=((ard[i]/min)-1); } printf(%d,ans); return 0; } On Sat, Mar 12, 2011 at 7:37 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
yeah I too got AC. The way I was calculating gcd was not efficient. :) On 3/12/11, Logic King crazy.logic.k...@gmail.com wrote: Here is my solution.i got it AC #includestdio.h 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(n0) scanf(%d,arr[0]); for(i=1;in;i++) { scanf(%d,arr[i]); ard[i]=arr[i]-arr[i-1]; if(i==1) min=ard[i]; else min=gcd(min,ard[i]); } for(i=1;in;i++) { ans+=((ard[i]/min)-1); } printf(%d,ans); return 0; } On Sat, Mar 12, 2011 at 7:37 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
which probem ? pls gve the link On Sat, Mar 12, 2011 at 8:27 PM, Akshata Sharma akshatasharm...@gmail.comwrote: yeah I too got AC. The way I was calculating gcd was not efficient. :) On 3/12/11, Logic King crazy.logic.k...@gmail.com wrote: Here is my solution.i got it AC #includestdio.h 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(n0) scanf(%d,arr[0]); for(i=1;in;i++) { scanf(%d,arr[i]); ard[i]=arr[i]-arr[i-1]; if(i==1) min=ard[i]; else min=gcd(min,ard[i]); } for(i=1;in;i++) { ans+=((ard[i]/min)-1); } printf(%d,ans); return 0; } On Sat, Mar 12, 2011 at 7:37 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kumar Anurag -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem
https://www.spoj.pl/problems/STREETR/ On 3/12/11, kumar anurag anurag.it.jo...@gmail.com wrote: which probem ? pls gve the link On Sat, Mar 12, 2011 at 8:27 PM, Akshata Sharma akshatasharm...@gmail.comwrote: yeah I too got AC. The way I was calculating gcd was not efficient. :) On 3/12/11, Logic King crazy.logic.k...@gmail.com wrote: Here is my solution.i got it AC #includestdio.h 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(n0) scanf(%d,arr[0]); for(i=1;in;i++) { scanf(%d,arr[i]); ard[i]=arr[i]-arr[i-1]; if(i==1) min=ard[i]; else min=gcd(min,ard[i]); } for(i=1;in;i++) { ans+=((ard[i]/min)-1); } printf(%d,ans); return 0; } On Sat, Mar 12, 2011 at 7:37 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: Yeah, I too am wondering how to implement more efficiently. On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @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 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kumar Anurag -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Interesting Toughest Problem On Telephone PC ..
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 pawelszc...@gmail.com wrote: 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.lenght1){ printChar(numbers[1:], currentString+letter) } else { print(currentString+letter) } } } On 11 Mar, 16:45, bittu shashank7andr...@gmail.com wrote: Hy Guys I want to do . for any phone number .. the program should print out all the possible strings it represents. For eg.) 2 in the number can be replaced by 'a' or 'b' or 'c', 3 by 'd' 'e' 'f' etc. In this way how many possible permutations can be formed from a given phone number. I don't want anyone to write code for it ... a good algorithm or psuedocode would be great. I am talking about old small phone where a single digit corresponds to 3charcter from digit 2 to 8 and digit 9 has 4 character w x y z ..Hope everyone got my points what i wants well i tried my solution but thats become so complex so now even i am facing to understand that so will anybody try this interesting question . more clearly for digit o/p is AD AE AF BD BE BF CD CE CF Now You Can Imegin what will be o/p for 9740852296 or any 10 digit number Think as much as you can but finally solution matters .. Thanks Regards Shashank Mani -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Bhavesh agrawal wants to chat
--- 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'll need to click this link to be able to chat with Bhavesh agrawal. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with Bhavesh agrawal, visit: http://mail.google.com/mail/a-b4f0875ca2-29d66a53f9-Tt0nFfpQ80JaH-2cWOceg6RZIxQ Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] SPoj maximum sum subseuence
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 vector #include map #include algorithm #include cstring #include iostream #include cstdio #include cmath #include cstdlib #include climits #define VI vector int typedef long long int LL; using namespace std; VI v; LL x,nos; //finding maximum sum subsequence LL findx() { int sz=v.size(); LL maxsum=INT_MIN; int maxstart=0,maxend=0; LL currentsum=0; int currentstart=0,currentend=0; for(currentend=0;currentendsz;currentend++) { currentsum=currentsum+v[currentend]; if(currentsummaxsum) { maxsum=currentsum; maxstart=currentstart; maxend=currentend; } if(currentsum0) { currentstart=currentend+1; currentsum=0; } } return maxsum; } // main Program int main() { // freopen(input.txt,r,stdin); int test; int num; map LL , LL m; cintest; LL sum=0; int n; int i; while(test--) { sum=0; nos=0; m.clear(); m[0]=1; scanf(%d,n); v.resize(n); for(i=0;in;i++) { scanf(%d,v[i]); } x=findx(); nos=0; for(i=0;in;i++) { sum=sum+v[i]; nos=nos+m[sum-x]; m[sum]++; } coutx nosendl; } return 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 to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.