/***
Bismillahir Rahmanir Rahim
Read the name of Allah, who created you!!!
Author : Shah Newaj Rabbi Shishir
Department of CSE, City University, Bangladesh.
***/
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner (System.in);
int n,i,len,k;
int []arr = new int [10];
char []Char = new char [10];
String str;
while (in.hasNext ())
{
n = in.nextInt ();
if (n == 0)
break;
BigInteger fact = BigInteger.valueOf (1);
for (i=1; i<=n; i++)
fact = fact.multiply (BigInteger.valueOf (i));
str = fact.toString();
Char = str.toCharArray();
len = Char.length;
for (i=0; i<10; i++)
arr[i] = 0;
for (i=0; i<len; i++)
{
k = Char[i] - '0';
arr[k]++;
}
System.out.println (n+"! --");
System.out.printf (" (0)%4d (1)%4d (2)%4d (3)%4d (4)%4d\n",arr[0],arr[1],arr[2],arr[3],arr[4]);
System.out.printf (" (5)%4d (6)%4d (7)%4d (8)%4d (9)%4d\n",arr[5],arr[6],arr[7],arr[8],arr[9]);
}
}
}
Bismillahir Rahmanir Rahim
Read the name of Allah, who created you!!!
Author : Shah Newaj Rabbi Shishir
Department of CSE, City University, Bangladesh.
***/
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner (System.in);
int n,i,len,k;
int []arr = new int [10];
char []Char = new char [10];
String str;
while (in.hasNext ())
{
n = in.nextInt ();
if (n == 0)
break;
BigInteger fact = BigInteger.valueOf (1);
for (i=1; i<=n; i++)
fact = fact.multiply (BigInteger.valueOf (i));
str = fact.toString();
Char = str.toCharArray();
len = Char.length;
for (i=0; i<10; i++)
arr[i] = 0;
for (i=0; i<len; i++)
{
k = Char[i] - '0';
arr[k]++;
}
System.out.println (n+"! --");
System.out.printf (" (0)%4d (1)%4d (2)%4d (3)%4d (4)%4d\n",arr[0],arr[1],arr[2],arr[3],arr[4]);
System.out.printf (" (5)%4d (6)%4d (7)%4d (8)%4d (9)%4d\n",arr[5],arr[6],arr[7],arr[8],arr[9]);
}
}
}
No comments:
Post a Comment