Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

small factorial

$
0
0
import java.util.*;

import java.io.*;

import java.math.BigInteger;


class test {
public static void main(String [] args)
{

 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


 try{

BigInteger one = BigInteger.ONE;
ArrayList<BigInteger> arr = new ArrayList<BigInteger>();

String str =br.readLine();     
String s= str;

int a = Integer.parseInt(s);

int lin = a;


while(a>0)
{
String str1 = br.readLine();
String s1 = str1;

int num=Integer.parseInt(s1);


for (int p=1; p<=num; p++) {
one = one.multiply(BigInteger.valueOf(p));
}
arr.add(one);       
a--;
}
for(int j=0;j<lin;j++)
{
System.out.println(arr.get(j));     
}
}
 catch(IOException ioe)
 {
     ioe.printStackTrace();
 }
}
}

could not get why i am getting time limit exceede in this code ??? plz hlp


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>