[algogeeks] c++ webservice in linux machine

2012-06-11 Thread rgap
Hi

i want to write a c++ webservice which should work in linux machine
with apache being the web server.

Are there any libraries which allow you to write server-side
applications that handle the HTTP requests with Apache being the
webserver on Linux?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Computing laboratory

2011-07-13 Thread rgap
someone¿

On Jul 7, 6:44 pm, rgap rgap...@gmail.com wrote:
 Hi.. can someone tell me about the Computing Laboratory you have on
 your faculty of computer science, what about the software, hardware
 there.
 Please i want to clarify my one doubts.
 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Computing laboratory

2011-07-07 Thread rgap
Hi.. can someone tell me about the Computing Laboratory you have on
your faculty of computer science, what about the software, hardware
there.
Please i want to clarify my one doubts.
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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Compiler Design Help

2011-04-15 Thread rgap
Send me links too, please

On Apr 10, 3:14 am, rahul rai raikra...@gmail.com wrote:
 None has been published  . If you want i can give you a two links to
 video courses , and some set of solved questions . Which will be good
 for compiler design help

 On 4/10/11, Harshal hc4...@gmail.com wrote:



  someone please share the solution manual of compiler design by Aho (aka
  dragon book)... I would be very grateful. Thanks..

  --
  Harshal.

  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Rahul

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Bit Magic ....Always Stuck ..

2011-03-01 Thread rgap
Is there a maximum time complexity¿

On Mar 1, 2:50 pm, bittu shashank7andr...@gmail.com wrote:
 Given an integer, print the next smallest and next largest number that
 have the same number of 1 bits in their binary representation.

 Example for n=12
 next smallest  with same no. of set bit is 17  but  to found next
 largest ..we have to be careful ..

 let c others ..??

 Thanks  Regards
 Shashank

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] A doubt...

2011-03-01 Thread rgap
H

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: A doubt...

2011-03-01 Thread rgap
Hi, does anybody know when/where to use

typedef long long int64;

and

const long double EPS = 1E-9;

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] UVA problem

2011-02-21 Thread rgap
Hi, I need help with this problem
http://uva.onlinejudge.org/index.php?option=com_onlinejudgeItemid=8page=show_problemproblem=38

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: MBINGO

2011-01-24 Thread rgap
Here is my implementation ;)

#include iostream
#include cstring
using namespace std;

int balls[91]; //maximum balls
int N;

//verify if its impossible to call out every number from 0 to N
bool impossible(){
   int i,j;
   if(!balls[0])return true; //if ball 0 was removed
 //its impossible to call 0
   for(i=1;i=N;++i){ //search all balls from 1 to N
   if(!balls[i]){ //if theres no ball i
   for(j=0;j=N-i;++j){ //Search a difference that results i
   //if there are 2 balls which their difference is i
   //number i can be called
   if(balls[j+i]balls[j])break; //j+i-j =
i //
   }
   //ball i cant be called
   if(j==N-i+1)return true;
   }
   }
   return false; //can be called all numbers from 0 to N
}

int main() {
   int B,i,cb;
   while(cinNB,N,B) {
   memset(balls,0,sizeof(balls));
   for(i=0;iB;++i){ //puts 1 - removed balls
   cincb;
   balls[cb]=1;
   }
   if(impossible()) coutN;
   else coutY;
   coutendl;
   }
   return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: MBINGO

2011-01-24 Thread rgap
You re right, but this code runs slower

#include iostream
#include cstring
#define ABS(x) ((x0)?(-(x)):(x))
using namespace std;

int main(){
   int N,B,i,j,k,c,dif;
   int R[91];
   int balls[91];
   while(cinNB,N,B){
   memset(balls,0,sizeof(balls));
   for(i=0;iB;++i)
   cinR[i];
   k=c=0;
   for(i=0;iB;++i){
   for(j=i+1;jB;++j){
   dif=ABS(R[i]-R[j]);
   if(!balls[dif]){balls[dif]=1; c++;}
   k++;
   }
   }
   if(c==N)coutY;
   else coutN;
   coutendl;
   }
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Count number of digits

2011-01-18 Thread rgap
How can i count the number of digits 0s,1s,2s,3s,... 9s
in a number n

for example if n=33902

number of 0s=1
number of 3s=2
number of 9s=1
number of 2s=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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Count number of digits

2011-01-18 Thread rgap
This code prints the number of digits 0,1,2,... 9sbetween A and B
How does it works?

#include iostream

using namespace std;

int pot10(int i) {
int n = 1;
while (i--) n *= 10;
return n;
}

int digits(int n, int d) {
if (n  10  n  d - 1) return d ? 1 : 0;
int s = 0, r = 0, i = 1;
int p = pot10(i);
while (n / (p / 10) = 1) {
if (!d) s -= 1 * (p / 10);
if ((n % p) ((d + 1) * (p / 10) - 2)) {
s += (n / p + 1) * p / 10;
r = 0;
} else {
r = (n % p)(d * (p / 10) - 2) ? (n % p)-(d * (p / 10) -
2) - 1 : 0;
s += (n / p) * (p / 10) + r;
}
i++;
p = pot10(i);
}
return s;
}

int main() {
int A, B, a, b, i;
while (cin  A  B, A, B) {
for (i = 0; i  9; i++) {
a = digits(A - 1, i);
b = digits(B, i);
cout  b - a   ;
}
a = digits(A - 1, i);
b = digits(B, i);
cout  b - a  endl;
}
return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Explanation problem ACM

2011-01-16 Thread rgap
The problem is from: 
http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=4813
Can someone explain me please what does this code do? why the GCD?

#include cstdio
#include algorithm
#include cmath
#include cstdlib
using namespace std;
int a[15],b[15],n,m,s,t;
int gcd(int c,int d)
{
if (d==0) return c;
return gcd(d,c%d);
}
int main()
{
int i,gg;
while (scanf(%d %d,n,m)==2n+m)
{
for (i=0;in;i++)
{
scanf(%d,a[i]);
}
sort(a,a+n);
n--;
if (n)
{
gg=a[1]-a[0];
for (i=1;in;i++)
gg=gcd(gg,a[i]-a[i-1]);
}
while (m--)
{
int s,t;
bool ans=true;
scanf(%d %d,s,t);
int d=abs(s-t);
if ( (d1)==1 )
ans=false;
if (n==0s+t!=a[0]*2)
ans=false;
d/=2;
if (ansn)
{
ans=false;
if (d%gg==0)
ans=true;
if (!ans)
{
int ss;
for (i=0;in+1!ans;i++)
{
ss=a[i]*2-s;
d=abs(ss-t);
if (d%2==0)
{
d/=2;
if (d%gg==0)
ans=true;
}
}
}
}
if (ans) printf(Y);
else printf(N);
if (m) printf( );
}
puts();
}
return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Correctness of an algorithm

2011-01-16 Thread rgap
please, how can i prove the correctness of an algorithm, for example
this one:

#include iostream
#include algorithm
#include stdio.h
using namespace std;

#define MAXN 12
int P[MAXN][20];
int T[MAXN];
int L[MAXN];
long long int C[MAXN];

int query(int p, int q){//lca
int tmp,log,i,c=0;
if(L[p]L[q])
swap(p,q);
for(log=1;1log=L[p];++log);
log--;
for(i=log;i=0;--i)
if(L[p]-(1i)=L[q])
p=P[p][i];
if(p==q)
return p;
for(i=log;i=0;--i){
if(P[p][i]!=-1  P[p][i]!=P[q][i]){
p=P[p][i];
q=P[q][i];
}
}
return T[p];
}

int main(){
int n,i,j,a,q;
long long int b;
T[0]=P[0][0]=0;
while(cinn  n){
for(i=1;in;++i)
for(j=1;1jn;++j)
P[i][j]=-1;
for(i=1;in;++i){
cinab;
T[i]=P[i][0]=a;
L[i]=L[a]+1;
C[i]=b+C[a];
}
for(j=1;1jn;++j){
for(i=0;in;++i){
if(P[i][j-1]!=-1)
P[i][j]=P[P[i][j-1]][j-1];
}
}
cinq;
for(i=0;iq;i++){
if(i) cout ;
cinab;
coutC[a]+C[b]-2*C[query(a,b)];
}
coutendl;
}
}

maybe using induction? please...

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] time complexity of sqrt(n)

2011-01-16 Thread rgap
What is the time complexity of sqrt function of 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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Problem from ACM ICPC 2010_2

2011-01-09 Thread rgap
I have solved the last one  :)
how can i solve this one:
http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=4805

using LCA, I used this algorithm:
http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor

but i dont know how to count the weights of the edges.

I have this code that prints the Lowest Common Ancestor:

#include iostream
#include stdio.h
using namespace std;

#define MAXN 12
int P[MAXN][20];//parent 16=log(MAXN)
int T[MAXN];//first parent
int L[MAXN];//level
int C[MAXN];//weight of edges

int query(int p, int q){
int tmp,log,i,c=0;
//if p is situated on a higher level than q then we swap them
if(L[p]L[q])
swap(p,q);
//we compute the value of [log(L[p)]
for(log=1;1log=L[p];++log);
log--;
//we find the ancestor of node p situated on the same level
//with q using the values in P
for(i=log;i=0;--i)
if(L[p]-(1i)=L[q])
p=P[p][i];
if(p==q)
return p;
//we compute LCA(p, q) using the values in P
for(i=log;i=0;--i){
if(P[p][i]!=-1  P[p][i]!=P[q][i]){
p=P[p][i];
q=P[q][i];
}
}
return T[p];
}

int main(){
//freopen(1.txt,r,stdin);
int n,i,j,a,b,q;
T[0]=P[0][0]=0;
while(cinn  n){
//preprocess;
for(i=1;in;++i)
for(j=1;1jn;++j)
P[i][j]=-1;
for(i=1;in;++i){
cinab;
T[i]=P[i][0]=a;
L[i]=L[a]+1;//level
C[i]=b;//weight
}
for(j=1;1jn;++j){
for(i=0;in;++i){
if(P[i][j-1]!=-1)
P[i][j]=P[P[i][j-1]][j-1];
}
}
cinq;//queries
for(i=0;iq;i++){
if(i) cout ;
cinab;
coutquery(a,b);
}
coutendl;
}
}

please, 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Problem from ACM ICPC 2010_2

2011-01-09 Thread rgap
Thanks, i finished it.   :)
it wasdist[i] + dist[j] - 2*dist[lca(i, j)]

this problem is difficult :(

http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=4809

I dont have idea how to solve it.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Problem from ACM ICPC 2010

2011-01-08 Thread rgap
Hi.. thanks for your response.

The number of kids:
3 = K = 10^9
I cant declare an array: long long A[10];

and how does dfs or bfs finds the components of the graph?

because i have to verify if there is a cycle in all the components.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Problem from ACM ICPC 2010

2011-01-07 Thread rgap
Hi, I need some help solving this problem from ICPC regionals, 2010,
South America.
http://acmicpc-live-archive.uva.es/nuevoportal/region.php?r=sayear=2010

Problem K - Kid's Wishes
Each kid may wish to sit down next to at most two other kids, because
each kid has just two neighbors in the circle. The teacher wants to
know whether it is possible to arrange the circle in such a way that
all kids’ wishes are satisfied.

give ideas please. please.
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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.