@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
https://www.spoj.pl/problems/NTKM/
my code is :
# includeiostream
# includecstdio
# includealgorithm
using namespace std;
int main()
{
long long int n;
while(1)
{
long long int a[1]={0},i;
if(scanf(%lld,n)==EOF)
break;
for(i=0;in;i++)
scanf(%lld,a[i]);
http://www.spoj.pl/problems/THRBL/
my code is
i am getting TLE
# includeiostream
# includecstdio
using namespace std;
//int search(long long int [],long long )
int main()
{
while(1)
{
int n,m;
int count=0;
long long int a[50010]={0};
int b[50010],c[50010];
if((scanf(%d%d,n,m))==EOF)
break;
int
@Karthik : Can you please the logic ??. Would be nice ..
On Fri, Jun 10, 2011 at 12:42 PM, kartik sachan kartik.sac...@gmail.comwrote:
http://www.spoj.pl/problems/THRBL/
my code is
i am getting TLE
# includeiostream
# includecstdio
using namespace std;
//int search(long long int [],long
what i understand from the problem was that.
n no of higests are given
and a and b and city no i.e from city a a ball is thrown to city no b
so i have done
from array a[] i.e hieght { n...no of times}
find all the element between b[i].city A and
i agree with the logici also implemented it...and getting TLE...there
must exist some better method :(
On Fri, Jun 10, 2011 at 2:18 AM, kartik sachan kartik.sac...@gmail.comwrote:
what i understand from the problem was that.
n no of higests are given
and a and b and city no
how should we get TLE loop total running less than 10^6??
--
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
Use Range Maximum Query.
On Fri, Jun 10, 2011 at 4:15 PM, kartik sachan kartik.sac...@gmail.comwrote:
how should we get TLE loop total running less than 10^6??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
u construct a tree nlogn , every node answers a query.. (or u get ans with a
recursion) in log(n) , so when u r doing a lot of query RMQ proves to be
very fast
On Fri, Jun 10, 2011 at 6:28 PM, nicks crazy.logic.k...@gmail.com wrote:
ya i saw that in the comments on spoj someone suggested to use
Suppose you are given an array a[]={2,3,1,4,6,7,10}
now for successfully transferring the ball,from ith city to jth city,a[i]
max(a[i..j-1]).
A naive approach would be to calculate all possible max[i][j] that is max
for each interval and then answer the query in 0(1) time.Another approach
would
http://www.spoj.pl/problems/IMPORT/
my code is
# includestdio.h
float max(float [],int);
void search(float [],char [],int ,float);
int p;
int main()
{
int t;
scanf(%d,t);
int i;
char ch[30]={0};
char a[30]={0};
float b[30]={0};
char f;
for(i=0;it;i++)
{
f=getchar();
thanks legobut why preprocessing all time avoided??
any drawback of it?
--
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
preprocessing is not at all a bad thing.There are certain problems where you
can avoid TLE by preprocessing only.Examples include doing RMQ.
But for this particular problem you are solving for all possible test cases
only few of which actually occur,Moreover there is no big advantage drawn
from
https://www.spoj.pl/problems/ETF/
vase saurabh bhai mere ho gya..
--
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
For all those who are still stuck with TLE,dont preprocess.The test data is
not that large and the time limit small.Just compute each query as it
arrives.I got AC this way only
On Tue, Jun 7, 2011 at 6:01 PM, kartik sachan kartik.sac...@gmail.comwrote:
https://www.spoj.pl/problems/ETF/
vase
Also make sure you don't write this code during a technical interview
... allocating 8 million bytes on the stack is not the way to go.
On Tuesday, June 7, 2011, saurabh singh saurab...@gmail.com wrote:
For all those who are still stuck with TLE,dont preprocess.The test data is
not that large
Can sum1 plz give me the link to the problem?
2011/6/5 keyan karthi keyankarthi1...@gmail.com
also tc page tat arun said says as follows...
1. If *p* is prime, then φ (*p*) = *p* - 1 and φ (*pa*) = *p** a* * (1
- 1/*p*) for any *a*.
2. If *m* and *n* are coprime, then φ (*m* * *n*)
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:
dude.. u code says pi(3) =3 as its a prime... but pi(3) is 2
in the same way pi(2)=2 as per ur code.. but ans is 1... mend ur code for
this... :)
On Sun, Jun 5, 2011 at 9:20 PM, kartik sachan kartik.sac...@gmail.comwrote:
@keyan then also it is given time limit exceed
i
also tc page tat arun said says as follows...
1. If *p* is prime, then φ (*p*) = *p* - 1 and φ (*pa*) = *p** a* * (1 -
1/*p*) for any *a*.
2. If *m* and *n* are coprime, then φ (*m* * *n*) = φ (*m*) * φ (*n*).
3. If *n* = , then Euler function can be found using formula:
φ (*n*) =
first time when i pre processed, my code timed out :P on calling it for
every loop iteration my code passed !! may be tats the problem...
On Sun, Jun 5, 2011 at 1:56 AM, kartik sachan kartik.sac...@gmail.comwrote:
@arun.i got nothing from this link becoz i have made the
program
read topcoder tutotial
http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=primeNumbers
hope will be useful
On Fri, Jun 3, 2011 at 5:33 PM, kartik kartik.sac...@gmail.com wrote:
what's worng in my code..why the judge is giving
TLE.plzz help me out
my code is
#
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)
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;
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
http://spoj.pl/problems/CHAIN
can any one suggest how to go about...
animals can have only 3 different roots... how do u maintain it..
like u just came across a new animal.. how do u put it in a group..
this cant be done just by parent[i]==i stuff rite?? how to make sure
that there is only 3
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??
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
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()
{
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
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
@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
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,
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
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
i'm trying to solve this problem..
https://www.spoj.pl/problems/TRAFFICN/ https://www.spoj.pl/problems/TRAFFICN/
here there are m edges.. in addition you are given k bi directional edges
out of which u can choose only one bi directional or u choose none of the
additional edges...
aim is to
bool fn(const floatc)
{//a^2+b^2=c
if (sqr(sqrt(c)) == c) //perfect square
{
float a=1; float b=c-1;
while(a=b){
float a2=a*a;
float b2=b*b;
if (a2+b2==c) return true;
if (a*2+b2c) { a+=1;}
else ( b-=1;}
}
}
return false;
}
Best Regards
Ashish Goel
Think positive and
sqr(sqrt(c)) == c
what ll it return if c is 10...
--
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
Depends on the parameter list of sqr function and also on type of c.If it
takes double as parameter and returns double than false else true,Correct me
if wrong,..
On Fri, May 27, 2011 at 8:56 AM, Balaji S balaji.ceg...@gmail.com wrote:
sqr(sqrt(c)) == c
what ll it return if c is 10...
--
I think your problem is you are using int. Use long long.
On Thu, May 26, 2011 at 12:29 AM, ricky moon.afr...@gmail.com wrote:
can anyone help me out with this problem:
https://www.spoj.pl/problems/TWOSQRS/
It runs on my machine with this code but it gives wrong ans on their
site.
Fermat's theorem will be better for this problem..:)
Cheers
~ Jeeva ~
On Thu, May 26, 2011 at 12:42 AM, Saikat Debnath crazysai...@gmail.comwrote:
I think your problem is you are using int. Use long long.
On Thu, May 26, 2011 at 12:29 AM, ricky moon.afr...@gmail.com wrote:
Fermat's little theroem ???
--
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
see
http://en.wikipedia.org/wiki/Fermat%27s_theorem_on_sums_of_two_squares
Hope it'll help...:)
Cheers
~ Jeeva ~
On Thu, May 26, 2011 at 9:17 AM, Balaji S balaji.ceg...@gmail.com wrote:
Fermat's little theroem ???
--
You received this message because you are subscribed to
@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
@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
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
@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
-
@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
@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
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
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
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.
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),...
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,
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
this is my code
--
#includeiostream
#includevector
#includestring.h
using namespace std;
vectorint tbf(100,0),array(100,0);
//vector 'tbf' denotes tobeflipped
void make(int ptr,int b,int e)
{
if(b==e)
{
array[ptr]=0;
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
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..
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
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
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,
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
I guess you solve it using binary search..
On Wed, Mar 23, 2011 at 6:48 PM, Vishnutej
mylavarapu.vishnu...@gmail.comwrote:
Hello everyone,
Im unable to understand the NUMGUESS problem in SPOJ.Can some one
explain what the problem is about?
Thanks in advance.
-Vishnutej.Mylavarapu
--
Yup...Its a binary search problem,Check wiki page of binary search for the
same problem
On Wed, Mar 23, 2011 at 8:14 PM, bharath kannan bharathgo...@gmail.comwrote:
I guess you solve it using binary search..
On Wed, Mar 23, 2011 at 6:48 PM, Vishnutej mylavarapu.vishnu...@gmail.com
wrote:
problem ka link bhi diya karo ya code..
On Sun, Mar 20, 2011 at 3:34 AM, sunny sunny.verma...@gmail.com wrote:
hello frnds...
i am getting TLE in 12th test case ..
can anyone over ther help me to shorten it..
#includestdio.h
#includeiostream
using namespace std;
int gcd(int a, int
@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
@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,
@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
@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
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
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
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
hello frnds...
i am getting TLE in 12th test case ..
can anyone over ther help me to shorten it..
#includestdio.h
#includeiostream
using namespace std;
int gcd(int a, int b)
{ if(b==0)
return(a);
else
return gcd(b,a%b);
}
int main()
{
int rec,g,count=0;
scanf(%d,rec);
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
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 =
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
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
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..
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()
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
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
@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
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
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
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
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--)
{
Hey Ankur,
Why dont u just modify the findx function itself to return the frequency of
occurence of maxsum as well.
On Sun, Mar 13, 2011 at 12:26 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
https://www.spoj.pl/problems/MAXSUMSQ/
Hi in above problem , i am getting TLE but according to
Can you explain your code ?
On Thu, Mar 10, 2011 at 10:22 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com
wrote:
WELL I HAVE DONE THIS PROBLEM .HERE IS THE CODE
#includestdio.h
#includealgorithm
using namespace std;
main()
{
long long int t[2][2010],price[2010],r,c,i,j,n;
@ankur: can u plz xplain ur approach??
On Sun, Mar 13, 2011 at 12:26 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
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
i used the following code..
getting wa
#includeiostream
#includealgorithm
#includevector
#includelimits.h
#includemap
using namespace std;
typedef unsigned long long int ull;
int main()
{
int t;
cint;
while(t--)
{
int n,sm=0;
scanf(%d,n);
vectorint v(n);
mapint,int mp;
for(int i=0;in;i++)
I tried the problem https://www.spoj.pl/problems/NHAY/
I didn't Understand the Input of the problem --
The length of the needle is only limited by the memory available to your
program, so do not make any assumptions - instead, read the length and
allocate memory as needed. The haystack is *not*
in order to deal with such situations u have to read the input till the end
of file
if your algo is correct then using EOF something like
while(scanf(%d,n)!=EOF) will give u AC..!!
On Sun, Mar 13, 2011 at 2:01 PM, Logic King crazy.logic.k...@gmail.comwrote:
I tried the problem
U didn't understand my problem.i have the problem with this line --
The length of the needle is only limited by the memory available to your
program, so do not make any assumptions - instead, read the length and
allocate memory as needed.
On Sun, Mar 13, 2011 at 4:00 PM, sukhmeet singh
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
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:
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
@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]);
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
@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
@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
101 - 200 of 257 matches
Mail list logo