hi i recently came across this problem..
there are K sets
each sets can contain n numbers from 0 to n
we've to choose exactly one number from each set
the sum of all the elements that we chose should be equal to P.
we have to find how many such possibilities are there to choose so..
for example
is it possible to print something without a main function??
I wonder how the code won't get any compile error
--
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
i'm trying out this problem www.spoj.pl/problems/ACODE
i'm getting TLE.. I donno y my recursion leads to tle
#includeiostream
#includemap
#includestdio.h
#includestring.h
using namespace std;
mapstring, long long ans;
mapstring, bool flags;
long long find(char *s, int len){
if(flags[s])
i'm trying to solve this spoj problem SHPATH / TSHPATH
i'm sure that my algorithm is correct
i'm getting Runtime error (SIGABRT) again and again
i've posted my code here http://ideone.com/O1qu3
help pls..
--
You received this message because you are subscribed to the Google Groups
Algorithm
http://www.spoj.pl/problems/HAROWS/
this is a spoj problem.. how to solve this problem??
--
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
given the sum and product of n numbers we have to find those
numbers(any one possibility)
sum, product and n are inputs...
for example if the sum is 10, product is 36 and n is 3
then 3,3,4 is a possible solution...
if it is impossible we should print NO
i wrote this code.. is there any faster
i just used that statement and cout it.. i got junk value..
what is the input format for this?
On Aug 13, 10:18 pm, Gaurav Menghani gaurav.mengh...@gmail.com
wrote:
It is just displaying the floating point in the specified precision
format. The internal representation is obviously unchanged.
there are n number of items available in the shop
price[] {size n} gives the cost of each item
and there are quantity[] {size n} means that there are quantity[i]
number of i'th item
the shop keeper provides some free items
if you buy k nos of item i, you will get 1 item j for free (i may be
equal
2 is pretty easy..
3: both
5: 6/12 * 6/11 = 3/11
am i right?
--
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
am using Dijkstra's algorithm for www.spoj.pl/TSHPATH
I'm getting WA.
someone plz help me..
#includeiostream
#includestring
#includestdio.h
#includestdlib.h
#includemap
using namespace std;
struct val{
int from;
int to;
};
bool operator (val a, val b){
if(a.from==b.from)
I'm trying to solve www.spoj.pl/problems/TSHPATH
getting WA :(
someone plz gimme a test case where my code fails
[code]#includeiostream
#includestring
#includestdio.h
#includestdlib.h
#includemap
using namespace std;
struct val{
int from;
int to;
};
bool operator (val a, val
i guess if the starting address of nr is same as any of previous nr's
address when re-allocating it will affect the bool operator (N a,N
b) function.. I don't know how to overcome it
so I tried with 2D static nr[1][1] which led me to
SIGKILL(exceeded memory)
--
You received this
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
.i...@gmail.comwrote:
@cegprakash
Expression resets the least significant set bit
On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote:
May be this can work.give any counter example...
int count;
main()
{
int l,rope,cuts;
scanf(%d%d,l
@mohit: nice soln :)
On Jul 2, 2:50 pm, mohit goel mohitgoel291...@gmail.com wrote:
May be this can work.give any counter example...
int count;
main()
{
int l,rope,cuts;
scanf(%d%d,l,rope);
count =0;
find_cuts(l,rope);
printf(cuts needed is %d,count);
@mohit: a little change in your function to make it work..
int find_cuts(int l,int rope)
int find_cuts(int l,int rope)
{
if(l==rope)
return count;
count++;
// printf(%d,count);
l=l/2;
if(l==rope)
return count;
if(ropel)
rope =rope-l;
return
PM, sunny agrawal
sunny816.i...@gmail.comwrote:
@cegprakash
Expression resets the least significant set bit
On Sat, Jul 2, 2011 at 3:20 PM, mohit goel
mohitgoel291...@gmail.comwrote:
May be this can work.give any counter example...
int count;
main()
{
int l,rope
i was actually trying this problem..
www.spoj.pl/problems/LQDCANDY
I'm getting WA still..
#includemath.h
#includestdio.h
int cnt;
inline int find_cuts(int l,int rope)
{
if(l==rope)
return cnt;
cnt++;
l=l/2;
if(l==rope)
return cnt;
if(ropel)
the length of the rope is l units.
I can only cut any rope into two halves.
for example if the length of the rope is 8 and we need a length of
rope 6
we first cut into two halves and we get 4, 4
now we cut any of the half again and we get 4,2,2
now we can merge 4 and 2 and form a rope of length
that will not work.
for example we need a rope of length 4 from a rope of length 16
we need 2 cuts
16== 8 + 8 == 8+ 4+ 4
--
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
PM, cegprakash cegprak...@gmail.com wrote:
the length of the rope is l units.
I can only cut any rope into two halves.
for example if the length of the rope is 8 and we need a length of
rope 6
we first cut into two halves and we get 4, 4
now we cut any of the half again and we get
initially m = 2;
after 1st iteration m = 4;
then break;
so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2.
On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote:
nope
On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote:
yup :)
On Sat, Jul 2, 2011 at 1:38 PM
* be the answer !!
On Sat, Jul 2, 2011 at 1:46 PM, cegprakash cegprak...@gmail.com wrote:
nope
On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote:
yup :)
On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah
shalinisah.luv4cod...@gmail.com
wrote:
i guess the no. of 1s
length
m = 2;
while(k % m)
m *= 2;
ans :: (log2(l) - log2(m) + 1).
ex.
k = 6,l = 8
so initially m = 2;
after 1st iteration m = 4;
then break;
so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2.
On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote:
nope
On Jul
@varun: i think it works.. could u tell me how u found 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
@ sunny: so your's doesn't work right?
--
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
@varun: explanation or proof for your soln. plz..
--
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
oh fine.. got it now.. set bit is '1' right.. and is there any short
ways to find the difference between first set and short set bit
without dividing by 2 repeatedly?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
-j will be the answer.
On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote:
oh fine.. got it now.. set bit is '1' right.. and is there any short
ways to find the difference between first set and short set bit
without dividing by 2 repeatedly?
--
You received
);
i-j will be the answer.
On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote:
oh fine.. got it now.. set bit is '1' right.. and is there any short
ways to find the difference between first set and short set bit
without dividing by 2 repeatedly?
--
You received
@ sunny
21 is 0
32 is 2
43 is 0
5 4 is 4
65 is 4
I don't find anything
--
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
power of 2 less than n right?
On Jul 2, 2:38 pm, cegprakash cegprak...@gmail.com wrote:
@ sunny
21 is 0
32 is 2
43 is 0
5 4 is 4
65 is 4
I don't find anything
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group
no no.. it should be multiple of 2 less than n? even that doesn't
satisfies for 43
On Jul 2, 2:41 pm, cegprakash cegprak...@gmail.com wrote:
power of 2 less than n right?
On Jul 2, 2:38 pm, cegprakash cegprak...@gmail.com wrote:
@ sunny
21 is 0
32 is 2
43 is 0
5 4 is 4
65 is 4
its ok :) but i'm not sir n all.. i'm a student :P
--
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
@kartik sachan:
I just compared your output file with the output file
for this test case
5 1 2 3 4 5
19 ab ab 100 50
20 20 20 75 75
10 0 ab 88 0
13 12 15.5 88 99
12 7 9 66 66
11 ab ab 99 100
your code outputs FAILED, 4.35 but actually he's PASSED, 7.20
I think you are assuming he's fail if he
simple..
sum all the n elements..
a= floor(sum/2)
b=sum-a
output is a b
--
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
nice explanation
On Apr 9, 1:15 pm, ArPiT BhAtNaGaR arpitbhatnagarm...@gmail.com
wrote:
COOL BRO THIS IS A GOOD SOLN
On Tue, Apr 5, 2011 at 4:10 PM, Azhar Hussain azhar...@gmail.com wrote:
Few Important things about macros, before I explain the output
1. Macros are replaced in
for the second case it is possible only if the node contains the
previous node's address. Else there should be data movement
--
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
thanks for sharing this question
--
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
I'm using a class. I use a destructor to free all the variables in the
class.
But still the stack gets overflow
I don't know how to free all the variables from main function
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
i know that in TURBOC there's a function called flushall()
what about in gcc?
--
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
@james curran: I was trying to solve the TMUL problem in spoj. I think
requires Karatsuba algorithm. I'm sure that my algorithm is fine. But
i get runtime error SIGABRT. that's y i'm asking.
#includeiostream
#includestdio.h
#includestdlib.h
#includestring.h
using namespace std;
class bigint{
i've to do a project for my end semester.. its very urgent..
i'm going to construct a 10*10 LED board
i've to display 2 digit numbers in the board by a micro controller
also i donno which language i should code..
In a clear way i've to control all the LED's using a program. If you
know any
click on register button on right top of the webpage. www.itrix.org.in
--
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
i=9;
switch(i){
default: printf(default);
case '1': printf(one); break;
case '2': printf(two); break;
case '9': printf(nine); break;
}
--
You received this message because you are subscribed to the Google Groups
Algorithm
i=9;
switch(i){
default: printf(default);
case '1': printf(one); break;
case '2': printf(two); break;
case '9': printf(nine); break;
}
why do i get defaultone as the output?
--
You received this message because you are
why do i get one after default?
--
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
i is not equal to '1'
i=1 which is equialent to 49
--
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
sorry i meant '1'=49
and 9 is not 49
but how we get one
--
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
i=9;
switch(i){
default: printf(default);
case 9: printf(one); break;
case '2': printf(two); break;
case '9': printf(nine); break;
}
but how the hell we get output for the above code as one .. why
default not printed
--
i=9;
switch(i){
xxx: printf(default);
yyy:printf(hello);
asdfasdf: printf(why no errors and why not printed);
case '1': printf(one);
default:
switch(i){
case '1': printf(one); break;
what is the use of labels in switch
--
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
@all: thank you :)
On Mar 21, 2:53 pm, bittu shashank7andr...@gmail.com wrote:
hope it will do that
unsigned int Log2n(unsigned int n)
{
return (n 1)? 1 + Log2n(n/2): 0;
}
Thank Regards
Shashank Mani
--
You received this message because you are subscribed to the Google Groups
Anurag's method is better than saurabh's
if u want to find the sum of digits from 1 to 1048
just apply Anurag's method from 1 to 1039 and saurabh's method from
1040 to 1048
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
no idea what the pattern is
--
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
hey i want to learn segment trees.. suggest me a tutorial plz.. pdf or
word anything..
i don't understand wiki page
--
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
hello... someone plz tell me how to arrive @ that formula..
--
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
now tell how u arrive at this formula?
On Mar 20, 6:25 am, Dave dave_and_da...@juno.com wrote:
Oops. Sorry. The correct formula is n*(n+2)*(2*n+1)/8.
Dave
On Mar 19, 5:26 pm, sunny sunny.verma...@gmail.com wrote:
this formula is giving wrong!!!.. :(
can u pls tell the approach
--
You
given a how to find the maximum value of n
if 2^n a
--
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
i dont know how to write a function which returns true 60% time and
false 40% time
--
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
how to find log2(a) in c++?
--
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
i'm having a biginteger in java.
how to find log2(number)??
help plz..
--
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
how to find the MSB position with order of 1?
--
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
i'm asking in java bigintegers
--
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
@gene: can u give the function for unfair_coin_toss so that i can
understand what u are doing in fair_coin_toss
On Mar 19, 9:54 am, Gene gene.ress...@gmail.com wrote:
On Friday, March 18, 2011 1:47:45 PM UTC-4, Gene wrote:
On Mar 17, 10:24 am, saurabh agrawal saura...@gmail.com wrote:
could someone plz help me with a pdf for learning segment tree? i
don't understand the wiki page
--
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,
could someone plz help me with a pdf for learning segment tree? i
don't understand the wiki page
--
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,
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
do anyone got this pattern?
On Mar 17, 6:16 pm, rohit scofiel...@rediffmail.com wrote:
'look and say ' (http://oeis.org/A005150) , begins 1, 11, 21, 1211,
111221, 312211, 13112221, 1113213211 ,
our task is to print this sequence.
example:
the sequence is: 1, 11 (or one 1), 21 (two 1's),
i've modified my algorithm
but i'm getting wrong answer. someone help..
#includeiostream
using namespace std;
unsigned long long start,end,arr[101],arr2[101];
int main(){
int j,t,i,n;
for(i=0;i100;i++){
arr[i]=i+1+arr[i-1];
}
for(i=0;i100;i++)
{
arr[i]+=arr[i-1];
}
arr2[1]=1;
so the fifth number should be 1231 na??
one 2 and three 1's in 1211
y not?
--
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
got it!! this just takes an order of number of digits in previous
number. why we need a general term? just precalculate and store in an
array na
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
my algo is working fine.. got acc:) :)
small error :P
--
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
are you planning to write in brainfuck?
On 15 March 2011 14:58, Natansh Verma natansh.ve...@gmail.com wrote:
I don't know about Windows 7, but there is an interpreter online, in
case you want one.
http://brainfuck.tk/
On Tue, Mar 15, 2011 at 5:15 PM, cegprakash
cegprak...@gmail.comwrote
@saikat: this place is only to share the algorithms and not the codes
--
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
75 matches
Mail list logo