You are not logged in. Please login at www.codechef.com to post your questions!

×

small factorial wrong answer

please tell me in which case it fails,it always shows wrong answer but when i compiled it in my compiler it ran successfully for any number.

include<stdio.h>

int main()

{int x,a[200]={0},i,j,k,m,n,b,temp;

scanf("%d",&n);

while(n--)

{scanf("%d",&b);

a[0]=1;

m=1;

for(i=2;i<=b;i++)

{temp=0;

for(j=0;j<m;j++)

{x=a[j]*i+temp;

a[j]=x%10;

temp=x/10;

}

while(temp!=0)

{a[m++]=temp%10;

temp=temp/10;

}

}

for(k=m-1;k>=0;k--)

printf("%d",&a[k]);

}

return 0;

}

asked 21 Jan '15, 11:52

shubham981's gravatar image

2★shubham981
01
accept rate: 0%


Check here: https://ideone.com/MADngZ

Your program is giving wrong answer for the sample test cases itself.

link

answered 21 Jan '15, 15:51

ketanhwr's gravatar image

6★ketanhwr
1.9k31844
accept rate: 15%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×186
×33

question asked: 21 Jan '15, 11:52

question was seen: 885 times

last updated: 21 Jan '15, 15:51