## Search found 12 matches

Sat Jan 19, 2008 2:38 pm
Forum: Volume 2 (200-299)
Topic: 264 - Count on Cantor
Replies: 47
Views: 14740

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 that is ret...
Tue Jan 01, 2008 7:12 am
Forum: Volume 101 (10100-10199)
Topic: 10183 - How Many Fibs?
Replies: 66
Views: 25075

### 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 len) { int i,j...
Sun Dec 23, 2007 8:15 am
Forum: Volume 1 (100-199)
Topic: 160 - Factors and Factorials
Replies: 205
Views: 28339

### 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,p,j; int fact,sum=0,c...
Sun Dec 23, 2007 4:10 am
Forum: Volume 103 (10300-10399)
Topic: 10361 - Automatic Poetry
Replies: 25
Views: 12909

### 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]=='>') { fl++; j=0; s[fl][...
Wed Sep 05, 2007 7:41 am
Forum: Volume 100 (10000-10099)
Topic: 10062 - Tell me the frequencies!
Replies: 235
Views: 41606

#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++) if(line[i]>31&&line...
Wed Aug 15, 2007 3:35 pm
Forum: Volume 100 (10000-10099)
Topic: 10035 - Primary Arithmetic
Replies: 328
Views: 64222

### 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++) { res=0; if((...
Wed Jul 25, 2007 8:01 pm
Forum: Volume 4 (400-499)
Topic: 488 - Triangle Wave
Replies: 270
Views: 36236
I've tried everything and still PE help plese #include<stdio.h> main() { int i,j,k,p,f=1; int amp=0,freq=0,test=0; scanf("%d",&test); for(p=1;p<=test;p++) { scanf("%d",&); scanf("%d",&freq); for(i=1;i<=freq;i++) { for(j=1;j<=amp;j++) { for(k=1;k<=j;k++) { printf("%d",j); } printf("\n"); } for(j=a...
Wed Jul 25, 2007 7:17 pm
Forum: Volume 100 (10000-10099)
Topic: 10062 - Tell me the frequencies!
Replies: 235
Views: 41606
I get PE for this problem Please help: #include<stdio.h> struct asci{ int val,pos; }; void main() { asci a[256],temp; int i=0,j=0; char line[1000]; while(gets(line)) { for(i=31;i<='z';i++) { a[i].pos=i; a[i].val=0; } for(i=0;line[i];i++) if(line[i]>31&&line[i]<='z') a[line[i]].val+=1; for(i=31;i<='z...
Tue Jan 02, 2007 5:54 pm
Forum: Volume 3 (300-399)
Topic: 392 - Polynomial Showdown
Replies: 93
Views: 19582

### 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(poly[i]<0&&flag) cout<<...
Mon Oct 09, 2006 8:06 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 203869

### 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; i = k;...
Mon Sep 04, 2006 2:51 am
Forum: Volume 5 (500-599)
Topic: 543 - Goldbach's Conjecture
Replies: 109
Views: 27028
HI,

I think you should generate prim numbers first and keep them in a array.
you only need to generate upto sqrt(1000000).And then substarct smallest primes from the number given and cheak wheather the ans is prime or not.

Sayeef
Sun Sep 03, 2006 12:22 pm
Forum: Volume 5 (500-599)
Topic: 514 - Rails
Replies: 79
Views: 26596

### 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("%d",&rail[1]...