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á http://lia.ufc.br/%7Ewladimir/ Homepage http://lia.ufc.br/%7Ewladimir/ | Maratonahttps://sites.google.com/site/quixadamaratona/| * On Fri, Sep 28,

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 wladimir...@gmail.comwrote: what happens when a = 3, d = 5 a, a + d, d +2, a +3 d = 3,8,13,18? Wladimir Araujo

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-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

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 asheesh...@gmail.com wrote: thanks for

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á http://lia.ufc.br/%7Ewladimir/ Homepage http://lia.ufc.br/%7Ewladimir/ | Maratonahttps://sites.google.com/site/quixadamaratona/| * On Thu, Sep 27, 2012 at 8:57 AM, atul

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] spoj problem EASYMATH

2012-09-25 Thread gaurav yadav
help needed in spoj problem EASYMATH http://spoj.pl/problems/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 the

[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

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 singhsourab...@gmail.comwrote: 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

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 hmonfa...@gmail.comwrote: use return (a/gcd(a,b)*b instead On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh singhsourab...@gmail.comwrote: please suggest something : Problem

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 sta) On Thu, Jun 21, 2012 at 12:34 PM, Mayank Singh singh13490may...@gmail.comwrote: here is my code /*#includestdio.h #includeconio.h int main() { int cand,sum; int T,N,i,j,temp[10];

Re: [algogeeks] SPOJ problem :STAMPS

2012-06-22 Thread Pradip Singh
use if(sum sta) instead of if(sum=sta) because in case sum==sta..your code will still increment p .but the value of p should not be incremented in this case.and in your output format colon : should be placed before \n to follow the format specified for the problem. On Fri, Jun 22, 2012 at 12:48

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-21 Thread Mayank Singh
my code is running perfectly well but giving WA in spoj.. #includestdio.h #includestdlib.h int main() { int cand,sum; int T,N,i,j,temp[10]; scanf(%d,T); sum = 0; for(i=0;iT;i++) { scanf(%d,N); for(j=0;jN;j++) { scanf(%d,cand);

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

[algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread Mayank Singh
here is my code : #includestdio.h #includestdlib.h 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;iT;i++) { scanf(%d,N); for(j=0;jN;j++) { scanf(%lld,cand);

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 singh13490may...@gmail.com wrote: here is my code : #includestdio.h #includestdlib.h int main() { long long cand,sum; int T,N,i,j,*temp; scanf(%d,T); temp=

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 PM,

[algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Mayank Singh
i am using long long but still getting WA. here's my code #includestdio.h #includeconio.h int main() { long long cand,sum; int T,N,i,j,temp[10]; scanf(%d,T); sum = 0; for(i=0;iT;i++) { scanf(%d,N); for(j=0;jN;j++) {

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

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

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

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

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

[algogeeks] spoj problem : POKER

2012-06-18 Thread Mayank Singh
here is my code: #includestdio.h #includestring.h #includestdlib.h 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;j15,k15;j=j+3,k1++)

[algogeeks] spoj problem : NSTEPS

2012-06-17 Thread Mayank Singh
here is my code for the above problem: #includestdio.h #includestdlib.h int main() { int i,x[1],y[1],val; long n; scanf(%d,n); for(i=0;in;i++) { scanf(%d,x[i]); scanf(%d,y[i]); } for(i=0;in;i++) { if(x[i] == y[i] x[i]%2 == 0)

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 singh13490may...@gmail.com wrote: here is my code for the above problem: #includestdio.h #includestdlib.h int main() {     int i,x[1],y[1],val;   

[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

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.. #includeiostream #includevector #includeset #includemap #includequeue #includestack #includestring #includealgorithm #includefunctional #includeiomanip

[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. * #includeiostream ** #includestdio.h using namespace std; int main() { long long int f,s,u,d,g,c,p;

Re: [algogeeks] spoj problem

2011-11-14 Thread shady
what;s your algorithm ? On Mon, Nov 14, 2011 at 7:57 PM, Anshul AGARWAL anshul.agarwa...@gmail.comwrote: 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. * #includeiostream **

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 sunny agrawal
one solution is use BFS On Mon, Nov 14, 2011 at 8:52 PM, Anshul AGARWAL anshul.agarwa...@gmail.com 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

[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 http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99

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] SPOJ Problem DIVSUM

2011-08-27 Thread Rahul Verma
I am trying to submit solution for the SPOJ DIVSUMhttps://www.spoj.pl/problems/DIVSUM/problem, but it returns the *time limit exceeded*. Code submitted by me is below: #include cstdlib #include iostream using namespace std; int proper_divisor(int number); int main() { int test,i,number;

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

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

[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

[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

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 sinv...@gmail.com 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

[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

[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 n0: return 0 if n==0: return 1 i=n

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 saurab...@gmail.com 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

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:

[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 iostream #include cstdio #include vector using namespace std; char * head; int result[5001]; int count(char * a ,int size)

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 #includestdio.h #includeiostream #includestring #includecstring 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;

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 keyan karthi
oops.. :P that an if didnt notice tat :D On Wed, Jun 1, 2011 at 8:34 PM, keyan karthi keyankarthi1...@gmail.comwrote: 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??

Re: [algogeeks] SPOJ Problem Help

2011-05-30 Thread oldman
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

[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*/ #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() {

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 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

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 aakashj@gmail.comwrote: Precompute the values. and then do queries. On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma

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 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

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 crazy.logic.k...@gmail.comwrote: @sukhmeetyour code is having runtime error !! On Sat, May 28,

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Akshata Sharma
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

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 email

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 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

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 ab.. this is for the special

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 email

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 (n1) mul(ans, A, d); mul(A, A, d); n =1; } -- Anshuman Mishra IIIT Allahabad -

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 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

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 akshatasharm...@gmail.comwrote: @sravanreddy001 by matrix exponential method, we can calculate the

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

[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

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 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.

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 technic@gmail.com wrote: Try thinking backwards. (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...

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 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,

[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: #includestdio.h #includestring.h int main() { int

[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 : #includestdio.h #includestring.h int compare(char s[], char t[]) { //only check second

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..

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

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 saurab...@gmail.com wrote: Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ I am getting TLE using binary search. Thanks in

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,

[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
@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 bharathgo...@gmail.comwrote: 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

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 20,

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 bharathgo...@gmail.comwrote: @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

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

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 anu.anurag@gmail.comwrote: @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

[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 #includeiostream #includeconio.h using namespace std; unsigned long long start,end,arr[101],arr2[101]; //number of triangles facing upwards=arr //number of triangles facing downwards=arr2

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 cegprak...@gmail.com wrote: Here is my code for TRICOUNT problem //http://www.spoj.pl/problems/TRICOUNT/ //cegprak...@gmail.com #includeiostream

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 kp101...@gmail.com wrote: Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find

[algogeeks] SPOJ Problem : PRIME1

2011-03-18 Thread samby
The problem goes like this : Peter wants to generate some prime numbers. Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases in a single line (t=10). In each of the next t lines there are two numbers m and n (1 = m = n =

Re: [algogeeks] SPOJ Problem : PRIME1

2011-03-18 Thread Anurag atri
you should try sieve of eratosthenes http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes there are far more efficient algorithms but i think this shoild be a good one to start with . ( even i got AC with this one :) ) On Fri, Mar 18, 2011 at 10:11 PM, samby ankitsamb...@gmail.com wrote: The

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-18 Thread Kunal Patil
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... When i read your mail and corresponding sorry mail...it just struck me..I also had to print YES and NOand i was printing NO as NoIt got ac den... :P thnx

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-17 Thread bharath kannan
sorry guyz... Had to print YES n NO.. i printed as Yes n No... Got ac.. Sorry for the trouble.. 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/BRCKTS am getting WA..

[algogeeks] SPOJ problem-BRCKTS

2011-03-16 Thread Bharath 2009503507 CSE
i am new to segment trees..i tried this problem in spoj.. http://www.spoj.pl/problems/BRCKTS am getting WA.. pls help... code: #includeiostream #includevector #includecstdio #includecmath #includestring using namespace std; class pi { public: int a,b; pi()

Re: [algogeeks] spoj problem

2011-03-15 Thread UTKARSH SRIVASTAV
well i have a doubt the test case says number could be as large as 10 and you have taken int but int does not have such range then how it is accepted On Sat, Mar 12, 2011 at 7:57 PM, Logic King crazy.logic.k...@gmail.comwrote: Here is my solution.i got it AC #includestdio.h int

Re: [algogeeks] spoj problem

2011-03-15 Thread Logic King
i Agree.the test cases for which problem is being jugdged might not have those larger values. On Tue, Mar 15, 2011 at 12:20 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: well i have a doubt the test case says number could be as large as 10 and you have taken int but

Re: [algogeeks] spoj problem

2011-03-15 Thread Ankur Khurana
@utraksh : 10^9 is well in int limits On Tue, Mar 15, 2011 at 12:56 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @utkarsh:teri kismat acchi thi aur kuch nhimaze kar! --- Satyam Kapoor B.Tech-2nd Year MNNIT-Allahabad. -- You received this message because

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Balaji Ramani
It fails for input 1,2,3. I think there needs to be one more iteration to check if the candidate is actually a majority element or not. Thanks, Balaji. On Tue, Mar 15, 2011 at 9:50 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: CAN ANYONE PLEASE TELL ME WHY MY CODE IS GIVING WRONG

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Akshata Sharma
hey link to the problem?? On Tue, Mar 15, 2011 at 10:50 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: It fails for input 1,2,3. I think there needs to be one more iteration to check if the candidate is actually a majority element or not. Thanks, Balaji. On Tue, Mar 15, 2011 at 9:50

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Balaji Ramani
http://www.spoj.pl/problems/MAJOR/ http://www.spoj.pl/problems/MAJOR/Thanks, Balaji. On Tue, Mar 15, 2011 at 11:00 PM, Akshata Sharma akshatasharm...@gmail.comwrote: hey link to the problem?? On Tue, Mar 15, 2011 at 10:50 PM, Balaji Ramani rbalaji.psgt...@gmail.com wrote: It fails for

Re: [algogeeks] Spoj Problem

2011-03-15 Thread UTKARSH SRIVASTAV
tahnks balaji i have got ac in this problem my prog is same only in the end i have taken a loop and @ akshata the link for the prob is https://www.spoj.pl/problems/MAJOR/ MY CODE IS #includestdio.h main() { long long int n,t,r[100],count,major,i; scanf(%lld,t); while(t--) {

  1   2   >