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

×

FACTRL2 WRONG ANSWER

include<iostream>

using namespace std;

int main() { int t,i=0; cin>>t; while(i<t) {="" int="" a[200];="" int="" n,r="0,q,l,k,g;" cin="">>n; if(n<7) { int ans=1; for(int b=1;b<=n;b++) ans=ans*b; cout<<"\n"<<ans; }="" a[0]="1;" for(q="1;q&lt;200;q++)" a[q]="0;" int="" m="1;" for(int="" j="2" ;="" j<="n" ;j++)="" {="" m="1;" for(k="0;k&lt;m;k++)" {="" int="" flag="1;" g="a[k]*j;" for(int="" d="k;d&lt;200;d++)" {="" flag="1;" if(a[d]="">0) { flag=0; break; } }

                if((g==0)&&(r==0)&&(flag==0))
                    {
                         m++;
                    }
                if((g==0)&&(r<10)&&(r>0))
                     {
                          m++;
                     }
                g+=r;
                l=g%10;
                a[k]=l;
                r=g/10;
                if(r>0)
                     m++;
           }
      }
      for(q=m-2;q>=0;q--)

           {
                cout<<a[q];
           }

      i++;
 }

}

//Ans is correct.

asked 17 Sep '17, 13:43

root00198's gravatar image

4★root00198
316
accept rate: 0%


its hard to read ur code but the questis pretty straignt forward u just need to find the favtorial!
a simple solution would be
ans=1
iterate i from 1 to n
ans*=i
(loop ends)
print ans

link

answered 17 Sep '17, 16:57

phantomhive's gravatar image

4★phantomhive
944
accept rate: 0%

cant because the value of 100! has more than 150 digits!!!. You cant use any DataType you have to use an array!!

(18 Sep '17, 00:48) root001984★
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:

×5

question asked: 17 Sep '17, 13:43

question was seen: 183 times

last updated: 18 Sep '17, 00:48