Search found 12 matches
- Sat Jan 19, 2008 2:38 pm
- Forum: Volume 2 (200-299)
- Topic: 264 - Count on Cantor
- Replies: 47
- Views: 22424
About Algo.....
You can do it Like this. You generatre all the summations upto 4775.
in a array val[].
formula is n(n+1)/2. When a Number is given then Binary search it. If u
find a match then cheak wheather it is even or odd. Then choose the
nom/dnom.
If you don't find the match then use the low index ...
- Tue Jan 01, 2008 7:12 am
- Forum: Volume 101 (10100-10199)
- Topic: 10183 - How Many Fibs?
- Replies: 66
- Views: 35839
I get WA for this problem
I keep Getting WA for this problem plz help
#include<stdio.h>
#include<string.h>
#define MAX 1050
int cmp(char a[],char b[] )
{
int al,bl;
al=strlen(a);
bl=strlen(b);
if(al!=bl)
return al-bl;
for(int i=0;a[i];i++)
{
if(a[i]!=b[i])
return a[i]-b[i];
}
return 0;
}
void strev(char *a,int ...
#include<stdio.h>
#include<string.h>
#define MAX 1050
int cmp(char a[],char b[] )
{
int al,bl;
al=strlen(a);
bl=strlen(b);
if(al!=bl)
return al-bl;
for(int i=0;a[i];i++)
{
if(a[i]!=b[i])
return a[i]-b[i];
}
return 0;
}
void strev(char *a,int ...
- Sun Dec 23, 2007 8:15 am
- Forum: Volume 1 (100-199)
- Topic: 160 - Factors and Factorials
- Replies: 205
- Views: 45178
I get PE 160 plz help
#include<stdio.h>
#include<math.h>
int prime[10000]={0};
void gen()
{
long i=0,j=0,chk=1,index=3;
prime[0]=1;
prime[1]=2;
prime[2]=3;
for(j=5;j<=10000;j++)
{
for(i=1;prime[i]<=sqrt(j);i++)
{
chk=j%prime[i];
if(chk==0)
break;
}
if(chk)
prime[index++]=j;
}
}
int main()
{
int i,k ...
- Sun Dec 23, 2007 4:10 am
- Forum: Volume 103 (10300-10399)
- Topic: 10361 - Automatic Poetry
- Replies: 25
- Views: 16717
I keep geting RE all the time can Anyone help ?? 10361
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,cas;
char ch1[10]={0};
gets(ch1);
cas=(int)atoi(ch1);
while(cas--)
{
int fl=0;
j=0;
char lin1[500]={'\0'},lin2[500]={'\0'},s[5][500]={'\0'},ch;
gets(lin1);
gets(lin2);
for(i=0;lin1[i];i++)
{
if(lin1[i]=='<'||lin1[i ...
- Wed Sep 05, 2007 7:41 am
- Forum: Volume 100 (10000-10099)
- Topic: 10062 - Tell me the frequencies!
- Replies: 235
- Views: 69528
Still PE please help..........
#include<stdio.h>
struct asci{
int val,pos;
};
void main()
{
//freopen("h:\\out2.txt","w",stdout);
asci a[256],temp;
int i=0,j=0,flag=0;
char line[1000];
while(gets(line))
{
if(flag)
printf("\n");
else
flag=1;
for(i=31;i<='z';i++)
{
a[i].pos=i;
a[i].val=0;
}
for(i=0;line[i];i ...
- Wed Aug 15, 2007 3:35 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10035 - Primary Arithmetic
- Replies: 328
- Views: 101808
I get WA.. For the following Code 10035
I get WA for this program...
#include<iostream>
#include<string>
using namespace std;
int main()
{
int count=0,chk,j,i;
while(1)
{
int res=0;
count=0;chk=0;
char s1[20]={0},s2[20]={0};
cin>>s1;
cin>>s2;
if(!(strcmp(s1,"0"))&&!(strcmp(s2,"0")))
break;
for(i=0,j=0;(s2[i]||s1[j]);i++,j ...
#include<iostream>
#include<string>
using namespace std;
int main()
{
int count=0,chk,j,i;
while(1)
{
int res=0;
count=0;chk=0;
char s1[20]={0},s2[20]={0};
cin>>s1;
cin>>s2;
if(!(strcmp(s1,"0"))&&!(strcmp(s2,"0")))
break;
for(i=0,j=0;(s2[i]||s1[j]);i++,j ...
- Wed Jul 25, 2007 8:01 pm
- Forum: Volume 4 (400-499)
- Topic: 488 - Triangle Wave
- Replies: 270
- Views: 64411
- Wed Jul 25, 2007 7:17 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10062 - Tell me the frequencies!
- Replies: 235
- Views: 69528
- Tue Jan 02, 2007 5:54 pm
- Forum: Volume 3 (300-399)
- Topic: 392 - Polynomial Showdown
- Replies: 93
- Views: 31647
I keep getin P.E for 392 plz help
This is the code can anyone tell me why I keep getting PE?
#include<iostream>
using namespace std;
int abs(int x)
{
if(x>=0)
return x;
return -x;
}
void main()
{
int poly[9]={0},i=0,flag,p;
while(cin>>poly[0])
{
flag=0;
for(i=1;i<9;i++)
{
cin>>poly[i];
}
for(i=0;i<9;i++)
{
if ...
#include<iostream>
using namespace std;
int abs(int x)
{
if(x>=0)
return x;
return -x;
}
void main()
{
int poly[9]={0},i=0,flag,p;
while(cin>>poly[0])
{
flag=0;
for(i=1;i<9;i++)
{
cin>>poly[i];
}
for(i=0;i<9;i++)
{
if ...
- Mon Oct 09, 2006 8:06 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317983
3n+1 problem
Hi there.
Your code is ok but for this problem. When you swap i with j then if you print it comes in a reverse order(if i>j). Like
input:
1 2
2 1
output:
1 2 2
1 2 2
but second one should b 2 1 2. the exact order the input was given.
so you do this:
int a,b;
a=i;b=j;
if (i > j){
k = j;
j = i ...
Your code is ok but for this problem. When you swap i with j then if you print it comes in a reverse order(if i>j). Like
input:
1 2
2 1
output:
1 2 2
1 2 2
but second one should b 2 1 2. the exact order the input was given.
so you do this:
int a,b;
a=i;b=j;
if (i > j){
k = j;
j = i ...
- Mon Sep 04, 2006 2:51 am
- Forum: Volume 5 (500-599)
- Topic: 543 - Goldbach's Conjecture
- Replies: 109
- Views: 41133
- Sun Sep 03, 2006 12:22 pm
- Forum: Volume 5 (500-599)
- Topic: 514 - Rails
- Replies: 79
- Views: 37667
514 WA
This is my code . I keep getting WA. why is that?? Can any one tell me?
#include<stdio.h>
void push(int);
int pop(void);
int stack[1001]={0},top=0;
void main()
{
int noc=0;
for(;;)
{
scanf("%d",&noc);
if(noc==0)
break;
for(;;)
{
int rail[1001]={0},i,flag=0,j,diff=0,large=0,k=1,p;
scanf ...
#include<stdio.h>
void push(int);
int pop(void);
int stack[1001]={0},top=0;
void main()
{
int noc=0;
for(;;)
{
scanf("%d",&noc);
if(noc==0)
break;
for(;;)
{
int rail[1001]={0},i,flag=0,j,diff=0,large=0,k=1,p;
scanf ...