[algogeeks] Spoj AMR10D

2013-08-31 Thread emmy
http://www.spoj.com/problems/AMR10D/ A number is a multiple of 11, when its digits are given alternate signs (starting with positive from right) and added w.r.t the signs gives a number modulo 11. The question is asking to partition the given numbers into two groups say S1 and S2 such that

Re: [algogeeks] Spoj FARIDA

2013-05-22 Thread Shashwat Anand
On Wed, May 22, 2013 at 9:45 AM, emmy foramlakh...@gmail.com wrote: problem : http://www.spoj.com/problems/FARIDA/ what is wrong with this code? The algorithm is pretty straight forward Is it ? 1000 1 1 1000 Your code gives 1001 as output. Desired output should be 2000. -- You received

[algogeeks] Spoj FARIDA

2013-05-21 Thread emmy
problem : http://www.spoj.com/problems/FARIDA/ what is wrong with this code? The algorithm is pretty straight forward #includestdio.h #includestdlib.h int main(void) { int t,n,i; scanf(%d,t); long long int s1,s2,s=0,a,temp; int c=1; while(t--) { scanf(%d,n);

[algogeeks] SPOJ ABA12C

2013-05-19 Thread piyush2011257
I have been trying to solve this problem - http://www.spoj.com/problems/ABA12C/ but am getting continuous WA. Now i have found a test case where my code gives wrong answer but am not able to find the fault in the logic. please help!! The code along with the test case for which i am getting

[algogeeks] SPOJ- MPILOT WA on 10th TEST FILE

2013-05-12 Thread Piyush Raman
I have been trying to solve this problem using DP. i managed to realize the problem in the form of recurrence.. The solution is: Suppose the task was : given N pilots you have to assign N/2 of them as captains and N/2 as assistances. Furthermore you need to do this in a way such that for every

Re: [algogeeks] SPOJ- MPILOT WA on 10th TEST FILE

2013-05-12 Thread Tian Guo
Could you post the test case you failed? Then we can have a check. 2013/5/12 Piyush Raman piyush2011...@gmail.com I have been trying to solve this problem using DP. i managed to realize the problem in the form of recurrence.. The solution is: Suppose the task was : given N pilots you have

Re: [algogeeks] SPOJ- MPILOT WA on 10th TEST FILE

2013-05-12 Thread Piyush Raman
The test cases are not public. Gonna have to find the bug in the logic! Here's the link of the problem statement: http://www.spoj.com/problems/MPILOT/ On Mon, May 13, 2013 at 1:36 AM, Tian Guo tian@epfl.ch wrote: Could you post the test case you failed? Then we can have a check.

Re: [algogeeks] SPOJ- MPILOT WA on 10th TEST FILE

2013-05-12 Thread Tian Guo
Great! Thanks! I think one possible problem is that for f[c][m], the range of m should bem= [0, min(c/2, n/2)] In your code, m is only related to n/2. 2013/5/12 Piyush Raman piyush2011...@gmail.com The test cases are not public. Gonna have to find the bug in the logic! Here's the

[algogeeks] SPOJ-NWERC11A TLE

2013-01-16 Thread Piyush Raman
http://www.spoj.com/problems/NWERC11A/ I have been trying to solve this problem but am getting TLE for larger inputs. Can't come up with an optimal approach!! --

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

2012-06-20 Thread algogeek
#includeiostream using namespace std; struct node { int num; int l,r; node * left; node * right; }; node * create(node * root,int start,int end); node * update(node * root, int i,int j); int query(node * root,int i,int j); main() { int n,q; cinnq; node *

[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 Problems SCUBADIV

2012-06-18 Thread Rituraj
Hi, I am trying to solve this problem. http://www.spoj.pl/problems/SCUBADIV/ But I am getting a lot of WAs! Any good logic(Solution) to solve the problem? Thanks in advance for your reply. Rituraj 2nd year B.Tech(CSE) NIT-Patna -- You received this message because you are subscribed to

[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

2012-02-14 Thread vickywiz
in 1 2 3 4 5 6...o/p ll b 5 -- 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/-/eWlM2oyysowJ. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] spoj

2012-02-13 Thread UTKARSH SRIVASTAV
not abe to get solution On Mon, Feb 13, 2012 at 10:49 AM, atul anand atul.87fri...@gmail.comwrote: what problem are you facing ...??? On Thu, Feb 9, 2012 at 12:01 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: I have been doing this question for a time but was not able to solve it.

Re: [algogeeks] spoj

2012-02-13 Thread atul anand
what will the output of following input: 1) 1 2 3 4 5 6 2) 1 2 3 4 5 6 7 i am bit confused.because in the given link for input 2 ...output is 2but it should be written in this foam 2 1... because 1 stands right of 2 so output should be 1... On Mon, Feb 13, 2012 at 1:41 PM, UTKARSH

Re: [algogeeks] spoj

2012-02-12 Thread atul anand
what problem are you facing ...??? On Thu, Feb 9, 2012 at 12:01 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: I have been doing this question for a time but was not able to solve it. It is based josephus problem ? Has anybody any idea http://www.spoj.pl/problems/WTK/ -- *UTKARSH

[algogeeks] Spoj Domino Tiling

2012-02-09 Thread Kunal Patil
I am solving spoj problem Tiling a Grid With Dominoes.(http://www.spoj.pl/problems/GNY07H/).. I am not able to come up with a recurrence relation.. One of my friend said it has the recurrence relation as f(n) = f(n-1) + 5*f(n-2) + f(n-3) - f(n-4). I am not convinced and have trouble deriving this

Re: [algogeeks] Spoj Domino Tiling

2012-02-09 Thread shady
well i have used three recurrences :P formed them by following a traditional approach f[i] = f[i-1] + 2*g[i-1] + h[i-1] + f[i-2]; g[i] = f[i-1] + g[i-1]; h[i] = f[i-1] + h[i-2]; On Thu, Feb 9, 2012 at 7:19 PM, Kunal Patil kp101...@gmail.com wrote: I am solving spoj

[algogeeks] spoj

2012-02-08 Thread UTKARSH SRIVASTAV
I have been doing this question for a time but was not able to solve it. It is based josephus problem ? Has anybody any idea http://www.spoj.pl/problems/WTK/ -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google

[algogeeks] Spoj ABCPATH

2012-02-02 Thread tr!n!ty
Hi all I was doing this problem on spoj and it is running correctly on my system and ideone. But when I submit it, it gives me SIGSEGV. Even after 2 days research I am unable to find the cause. Please help!!! The code is http://ideone.com/8aZLM PS- If it shows correct

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

Re: [algogeeks] spoj problem:Street parade

2011-12-20 Thread sharad dixit
@Anshul AGARWAL Input : 4 2 1 3 4 Expected Output : Yes Your's Code Output : No On 12/20/11, sunny agrawal sunny816.i...@gmail.com wrote: @ Anshul it will be nice if you post your logic rather than Code, and also Code posting without logic and comments is not allowed in the group. i don't

Re: [algogeeks] spoj problem:Street parade

2011-12-20 Thread Anshul AGARWAL
Thanx Sharad finally got AC *Anshul Agarwal Nit Allahabad Computer Science** * On Tue, Dec 20, 2011 at 3:16 PM, sharad dixit sharad.emine...@gmail.comwrote: @Anshul AGARWAL Input : 4 2 1 3 4 Expected Output : Yes Your's Code Output : No On 12/20/11, sunny agrawal

[algogeeks] SPOJ TLE

2011-12-05 Thread varma C.S.P
I am getting a lot of tle's for this problem. https://www.spoj.pl/problems/BUGLIFE/ Here is my code #includeiostream #includecstdio #includecstring using namespace std; int g[2001][2001]; int color[2001]; short stack[5001]; int bugs, rel; int inline complement(int n); bool inline dfs(); int

[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

Re: [algogeeks] [SPOJ] ZSUM

2011-10-25 Thread Kunal Patil
Can you tell why (x * z * z) % MOD is different from (x * ( (z*z)%MOD) ) % MOD Again why ((x%MOD)*(z%MOD)*(z%MOD))%MOD is giving WA I thought of a simple examples like (100* 53*72) % 90 -- ((90+10)*53*72) % 90 -- (10*53*72)% 90 which is same as (100%90 * 53%90 * 72%90) % 90 Another

Re: [algogeeks] [SPOJ] ZSUM

2011-10-25 Thread Aamir Khan
As far as modular arithmetic is concerned, (x * z *z )%MOD = (x *(z *z)%MOD)%MOD = ((x%MOD)*(z%MOD)*(z%MOD))%MOD But when you try to calculate *(x * z * z)%MOD*, the intermediate result of* (x * z * z) *overflows the integer limit and hence gives the wrong result. similarly, intermediate value

Re: [algogeeks] [SPOJ] ZSUM

2011-10-20 Thread Wasif Hossain
Just a MINOR change. please change the RED line(I've marked it below) in your code by the following line: *return (x*((z*z)%MOD))%MOD;* and enjoy an *ACCEPTED *verdict.* * *Wasif Hossain** * B.Sc. Student of Final Semester, Computer Science and Engineering(CSE), Bangladesh University of

[algogeeks] [SPOJ] ZSUM

2011-10-05 Thread hashd
I'm getting WA on the question : ZSUM-SPOJhttps://www.spoj.pl/problems/ZSUM/ Here is my code: Let me know if you can find the problem with the code #includecstdio #define MOD 1007 typedef unsigned long long u64; using namespace std; u64 modExp(u64 x, u64 y){ if(x==0) return 0;

[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

[algogeeks] SPOJ PIE

2011-09-15 Thread KK
http://www.spoj.pl/problems/PIE/ I solved this using Binary Search its similar to shake shake shaky of spoj... but still get WA :( Plzz help... #includeiostream #includealgorithm using namespace std; bool solve(int *pie, int n, int mid,int f) { int sum = 0; for (int i=0; in; i++)

Re: [algogeeks] SPOJ PIE

2011-09-15 Thread Gaurav Menghani
One small observation, you can use the M_PI constant already available when you #include cmath On Thu, Sep 15, 2011 at 3:57 PM, KK kunalkapadi...@gmail.com wrote: http://www.spoj.pl/problems/PIE/ I solved this using Binary Search its similar to shake shake shaky of spoj... but still get WA :(

[algogeeks] SPOJ

2011-09-06 Thread Akshata Sharma
I am getting WA in this problem, I am not getting what i am doing wrong . http://www.spoj.pl/problems/AE2A/ My dp is: dp[n][k] = (dp[n - 1][k - 1] + dp[n - 1][k - 2] + dp[n - 1][k - 3] + dp[n - 1][k - 4] + dp[n - 1][k - 5] + dp[n - 1][k - 6]) and my code: #includeiostream using namespace

Re: [algogeeks] SPOJ

2011-09-06 Thread Gaurav Menghani
Description of the problem and your solution could help others. On Wed, Sep 7, 2011 at 12:01 AM, Akshata Sharma akshatasharm...@gmail.com wrote: I am getting WA in this problem, I am not getting what i am doing wrong . http://www.spoj.pl/problems/AE2A/ My dp is: dp[n][k] = (dp[n - 1][k -

Re: [algogeeks] SPOJ

2011-09-06 Thread Akshata Sharma
@rahul, yes i agree with what you said, but I don't think that this is causing WA here.. Its equivalent as if u take 2 1-darrays.. right? On Wed, Sep 7, 2011 at 8:25 AM, rahul vatsa vatsa.ra...@gmail.com wrote: if you are allocating memory for a n-d array, u shouldn't allocate memory for each

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 ACODE

2011-08-26 Thread kartik sachan
i am getting repeatdly WA in this question link is https://www.spoj.pl/problems/ACODE/ plzz provide me some test cases where my code fails. my code is # includecstdio # includecstring int main() { while(1) { char a[50100]; scanf(%s,a);

[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 coin tossing

2011-08-24 Thread shashi kant
http://www.se.cuhk.edu.hk/~seem3570/12-pattern.pdf here is the solution to this On Wed, Aug 24, 2011 at 7:25 AM, keyankarthi keyankarthi1...@gmail.comwrote: http://www.spoj.pl/problems/MAIN8_D/ i tried solving this problem any ideas...?? for second test case 'htht' the states i

Re: [algogeeks] spoj coin tossing

2011-08-24 Thread keyan karthi
thanks *Shashi* !!! http://deepblue.lib.umich.edu/bitstream/2027.42/24435/1/708.pdf this one is good to :) On Wed, Aug 24, 2011 at 5:32 PM, shashi kant shashiski...@gmail.com wrote: http://www.se.cuhk.edu.hk/~seem3570/12-pattern.pdf here is the solution to this On Wed, Aug 24,

Re: [algogeeks] spoj coin tossing

2011-08-24 Thread keyan karthi
^typo On Wed, Aug 24, 2011 at 6:46 PM, keyan karthi keyankarthi1...@gmail.comwrote: thanks *Shashi* !!! http://deepblue.lib.umich.edu/bitstream/2027.42/24435/1/708.pdf this one is good to :) On Wed, Aug 24, 2011 at 5:32 PM, shashi kant shashiski...@gmail.comwrote:

[algogeeks] spoj- coin tossing

2011-08-23 Thread keyan karthi
http://www.spoj.pl/problems/MAIN8_D/ i tried solving this problem any ideas...?? for second test case 'htht' the states i considered are 1 T - (1/2) * x+1 2 HH - (1/4) * x+2 3 HTT - (1/8) * x+3 4 HTHH - (1/16) * x+4 5 HTHT - (1/16)(final state) x is the expected no

[algogeeks] spoj coin tossing

2011-08-23 Thread keyankarthi
http://www.spoj.pl/problems/MAIN8_D/ i tried solving this problem any ideas...?? for second test case 'htht' the states i considered are 1 T - (1/2) * x+1 2 HH - (1/4) * x+2 3 HTT - (1/8) * x+3 4 HTHH - (1/16) * x+4 5 HTHT - (1/16)(final state) x is the expected no

Re: [algogeeks] SPOJ 9199. Circular Track

2011-08-17 Thread Prakash D
any1?? On Sun, Aug 7, 2011 at 7:16 PM, Prakash D cegprak...@gmail.com wrote: yeah, i also need to know the approach for this kind of problems asked in many places On Sun, Aug 7, 2011 at 3:58 PM, arvind kumar arvindk...@gmail.com wrote: Hi Can any1 pls help me in solving this? Two

Re: Re: [algogeeks] SPOJ 9199. Circular Track

2011-08-17 Thread vaibhavmittal11
divide absolute speeds by their GCD..and then the answer is their relative speed.. VM NSIT, Dwarka 3rd year, COE On , Prakash D cegprak...@gmail.com wrote: any1?? On Sun, Aug 7, 2011 at 7:16 PM, Prakash D cegprak...@gmail.com wrote: yeah, i also need to know the approach for this kind

[algogeeks] SPOJ CENCRY

2011-08-09 Thread kartik sachan
this is my codeplz give me any test case where my code fails.i am reaptedly getting WA link is https://www.spoj.pl/problems/CENCRY/ # includecstdio # includecstring char a[]=aeiouaeiouaeiouaeioua; char b[]=bcdfghjklmnpqrstvwxyz; int search(char a1) { int i;

[algogeeks] SPOJ 9199. Circular Track

2011-08-07 Thread arvind kumar
Hi Can any1 pls help me in solving this? Two persons are running on a circular track either in the same direction or in the opposite direction, indefinitely. The speed of both of them is given to you. Speed will be positive in clockwise direction, and negative in anticlockwise direction. Print the

Re: [algogeeks] SPOJ 9199. Circular Track

2011-08-07 Thread Prakash D
yeah, i also need to know the approach for this kind of problems asked in many places On Sun, Aug 7, 2011 at 3:58 PM, arvind kumar arvindk...@gmail.com wrote: Hi Can any1 pls help me in solving this? Two persons are running on a circular track either in the same direction or in the opposite

[algogeeks] SPOJ ABCD

2011-08-06 Thread Amol Sharma
i attempted a problem http://www.spoj.pl/problems/ABCD/ my logic is scan the input string and record the count of A, B, C, D in array of size 4 now sort the count array in the output array at first position put an element from count array whose count is less than n and not equal to

[algogeeks] SPOJ LITE

2011-08-01 Thread Amol Sharma
hi everyone...i came across a quite simple problem on spoj... https://www.spoj.pl/problems/LITE/ obvious solution will be O(n)...but it is getting TLE... so we have to improve the complexity to O(logn)..can some suggest the segment tree implementation of this problem i am new to segment

[algogeeks] SPOJ

2011-07-23 Thread KK
www.spoj.pl/problems/SHOP Its a pretty easy Q... But m not able to figure out any silly mistake in my prog.. plzz help #includeiostream #includevector #includemap #includequeue using namespace std; char a[26][26]; int si, sj, di, dj, rows, cols; void BFS(vector vectorint v, int si, int sj,

Re: [algogeeks] SPOJ

2011-07-23 Thread shady
there's something called spoj forum, try posting it there secondly, ask whether ur algo is right or wrong, not the code On Sat, Jul 23, 2011 at 4:51 PM, KK kunalkapadi...@gmail.com wrote: www.spoj.pl/problems/SHOP Its a pretty easy Q... But m not able to figure out any silly mistake in my

Re: [algogeeks] SPOJ

2011-07-23 Thread viswanath vellaiappan
I agree with Shady on asking for algo for the problem but lets not be hard on posting spoj question on spoj forum as these too involves algorithm (our interest). @KK : Can you tell us the judging status you are hitting? (Wrong answer, timeout??). ~Viswanath. On Sat, Jul 23, 2011 at 4:57 PM,

Re: [algogeeks] SPOJ

2011-07-23 Thread Piyush Kapoor
What will happen if r=di,c=dj in your safe function,I think that is causing the error... On Sat, Jul 23, 2011 at 8:29 PM, viswanath vellaiappan viswanath.vellaiap...@gmail.com wrote: I agree with Shady on asking for algo for the problem but lets not be hard on posting spoj question on spoj

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

2011-06-28 Thread kartik sachan
http://www.spoj.pl/problems/GPA1/ hey guys here is my code and its given WA ...plzz tell me where i am worng..i am tried getting WA in this question # includestdio.h # includestdlib.h int main() { int n; scanf(%d,n); while(n--) { double a,b,c,d,e,f; double

[algogeeks] SPOJ STRDIST

2011-06-26 Thread ganesha
http://www.spoj.pl/problems/STRDIST/ Getting WA repeatedly. Can someone help me with the below code. #include iostream #include string #include stdio.h #include algorithm using namespace std; int main() { int k,l; scanf(%d %d,k,l); string str1 = ; string str2

Re: [algogeeks] spoj shlights

2011-06-23 Thread Jitendra singh
@ kartik sachan Problem with this code is this- All GB pairs should be process in one time period On 6/23/11, kartik sachan kartik.sac...@gmail.com wrote: QUESTION LINK IS http://www.spoj.pl/problems/SHLIGHTS/ MY CODE IS GIVEN BELOW ITS IS GIVING TLEPLZZ HELP ME OUT #

[algogeeks] spoj shlights

2011-06-22 Thread kartik sachan
QUESTION LINK IS http://www.spoj.pl/problems/SHLIGHTS/ MY CODE IS GIVEN BELOW ITS IS GIVING TLEPLZZ HELP ME OUT # includecstdio # includecstring int main() { int t; char a[17]; scanf(%d,t); int i,j,k; while(t--) { int count=0; int flag=0,flag1=0;

[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

  1   2   3   >