we know fact(n)=nfact(n-1)
->fact(n-1)=fact(n)/n
->fact(n)=fact(n+1)/(n+1)
if n=-1 ,
-1!=fact(0)/0=infinity so overflow
if n=-2
-2!=fact(-1)/(-1)=-infinity so underflow
nd so on
Search found 16 matches
- Mon Jul 25, 2005 3:59 am
- Forum: Volume 103 (10300-10399)
- Topic: 10323 - Factorial! You Must be Kidding!!!
- Replies: 106
- Views: 47458
- Mon Sep 13, 2004 10:24 am
- Forum: Volume 105 (10500-10599)
- Topic: 10591 - Happy Number
- Replies: 61
- Views: 30979
10591
i found the fault myself,yet thanx to raiyan
Code: Select all
[cpp]
the code has been cut
[cpp]
- Thu Mar 11, 2004 7:40 am
- Forum: Volume 1 (100-199)
- Topic: 111 - History Grading
- Replies: 135
- Views: 37025
why wa 111 history grading
i used lcs for this prigram so why wa?
[cpp]#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int cor[40],stu[40],array[40][40],n;
void work()
{
int i,j;
for(i=0;i<40;i++)
memset(array ,0,sizeof(int)*40);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
if(stu ==cor[j])
array[i+1][j+1]=array [j ...
[cpp]#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int cor[40],stu[40],array[40][40],n;
void work()
{
int i,j;
for(i=0;i<40;i++)
memset(array ,0,sizeof(int)*40);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
if(stu ==cor[j])
array[i+1][j+1]=array [j ...
- Wed Mar 10, 2004 11:37 am
- Forum: Volume 100 (10000-10099)
- Topic: 10006 - Carmichael Numbers
- Replies: 66
- Views: 29542
10006
i can't understand why it is wa?
[cpp]
what a funny mistake
[/cpp]
[cpp]
what a funny mistake
[/cpp]
- Tue Mar 09, 2004 3:49 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10013 - Super long sums
- Replies: 212
- Views: 67621
- Tue Mar 09, 2004 11:39 am
- Forum: Volume 100 (10000-10099)
- Topic: 10013 - Super long sums
- Replies: 212
- Views: 67621
- Tue Mar 09, 2004 11:36 am
- Forum: Volume 4 (400-499)
- Topic: 482 - Permutation Arrays
- Replies: 159
- Views: 53377
- Tue Mar 09, 2004 9:54 am
- Forum: Volume 100 (10000-10099)
- Topic: 10033 - Interpreter
- Replies: 88
- Views: 39287
10033
why it is wa?i am confused about input 000.will i then increase instruction?
[cpp]#include<stdio.h>
#include<string.h>
long int ram[1001],r[11];
int main()
{
long int test,n,ip,i,k;
int f,d,s;
scanf("%ld",&test);
for(k=0;k<test;k++)
{
i=0;
ip=0;
while(1==(scanf("%ld",&ram[i++])));
for ...
[cpp]#include<stdio.h>
#include<string.h>
long int ram[1001],r[11];
int main()
{
long int test,n,ip,i,k;
int f,d,s;
scanf("%ld",&test);
for(k=0;k<test;k++)
{
i=0;
ip=0;
while(1==(scanf("%ld",&ram[i++])));
for ...
- Tue Mar 09, 2004 9:21 am
- Forum: Volume 100 (10000-10099)
- Topic: 10032 - Tug of War
- Replies: 91
- Views: 43597
Re: help about 10032
is my algorithm correct?
need some input&output.
at first i sorted the iputs.entered 1st man in group1&2nd man in group 2.
kept track for man in 2 groups with man1&man2 variable.
then for every next input checked if there is equal man in 2 groups.
if man number is equal then checked in which group ...
need some input&output.
at first i sorted the iputs.entered 1st man in group1&2nd man in group 2.
kept track for man in 2 groups with man1&man2 variable.
then for every next input checked if there is equal man in 2 groups.
if man number is equal then checked in which group ...
- Mon Mar 08, 2004 4:18 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10032 - Tug of War
- Replies: 91
- Views: 43597
10032
is my algorithm correct?
need some input&output.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n;
int a[105];
void input()
{
int i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a );
return;
}
void work()
{
int temp,i,j,k,p1,p2,t1,t2,man1,man2,test;
scanf("%d",&test);
for(k=0 ...
need some input&output.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n;
int a[105];
void input()
{
int i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a );
return;
}
void work()
{
int temp,i,j,k,p1,p2,t1,t2,man1,man2,test;
scanf("%d",&test);
for(k=0 ...
- Mon Mar 08, 2004 4:15 pm
- Forum: Volume 4 (400-499)
- Topic: 482 - Permutation Arrays
- Replies: 159
- Views: 53377
why compile error 482
why compile error?
is my algorithm correct?
[cpp]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000000];
char array[1000000][1000];
char str[1000000],s[1000];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in ...
is my algorithm correct?
[cpp]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000000];
char array[1000000][1000];
char str[1000000],s[1000];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in ...
- Mon Mar 08, 2004 4:12 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10013 - Super long sums
- Replies: 212
- Views: 67621
10013
why it's wa?i need some input& output.
is my algorithm correct?then why wa?
#include<stdio.h>
int d1,d2;
long int n,m,i,j,num;
int a[1000001];
int main()
{
int c,k;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
scanf("%ld",&m);
for(j=0;j<m;j++)
{
scanf("%d %d",&d1,&d2);
a[j]=(d1+d2)%10;
c=(d1 ...
is my algorithm correct?then why wa?
#include<stdio.h>
int d1,d2;
long int n,m,i,j,num;
int a[1000001];
int main()
{
int c,k;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
scanf("%ld",&m);
for(j=0;j<m;j++)
{
scanf("%d %d",&d1,&d2);
a[j]=(d1+d2)%10;
c=(d1 ...
- Sun Mar 07, 2004 8:08 pm
- Forum: Volume 4 (400-499)
- Topic: 482 - Permutation Arrays
- Replies: 159
- Views: 53377
why compile error 482
why compile error?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000];
char array[1000][20];
char str[1000],s[100];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in=0;
gets(str);
len=strlen(str);
for(i=0;i ...
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000];
char array[1000][20];
char str[1000],s[100];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in=0;
gets(str);
len=strlen(str);
for(i=0;i ...
- Sun Mar 07, 2004 12:30 pm
- Forum: Volume 4 (400-499)
- Topic: 489 - Hangman Judge
- Replies: 52
- Views: 23809
489 why wa
why wa?
need some sample input&output
my coding:
[cpp]
#include<stdio.h>
#include<string.h>
int posn[258],travel[258],nmtrv[258];
int main()
{
long int num,i,in;
char str[10000],res[10000],s[5];
long int match=0,notm=0,len,len1;
for(;;)
{
scanf("%ld",&num);
gets(s);
if(num==-1)
break ...
need some sample input&output
my coding:
[cpp]
#include<stdio.h>
#include<string.h>
int posn[258],travel[258],nmtrv[258];
int main()
{
long int num,i,in;
char str[10000],res[10000],s[5];
long int match=0,notm=0,len,len1;
for(;;)
{
scanf("%ld",&num);
gets(s);
if(num==-1)
break ...
- Sun Mar 07, 2004 12:28 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10008 - What's Cryptanalysis?
- Replies: 55
- Views: 27220
help about 10008
why wa?
#include<stdio.h>
#include<ctype.h>
#include<string.h>
struct freq{
char c;
unsigned long int f;
};
struct freq letter[26];
unsigned long int i,n,l,j;
int index;
char str[150000000];
int main(){
scanf("%lu",&n);
for(;n>0;n--){
fflush(stdin);
gets(str);
l=strlen(str);
for(i=0 ...
#include<stdio.h>
#include<ctype.h>
#include<string.h>
struct freq{
char c;
unsigned long int f;
};
struct freq letter[26];
unsigned long int i,n,l,j;
int index;
char str[150000000];
int main(){
scanf("%lu",&n);
for(;n>0;n--){
fflush(stdin);
gets(str);
l=strlen(str);
for(i=0 ...