//java solution
import java.io.*;
import java.math.*;
import java.util.*;
class Main
{
public static void main (String args[]) // entry point from OS
{
Main myWork = new Main(); // create a dynamic instance
myWork.Begin(); // the true entry point
}
void Begin()
{
try
{
int n;
BigInteger b=new BigInteger("1");
Scanner sc=new Scanner(System.in);
PrintWriter pr=new PrintWriter(System.out);
String sss;int ttx;
while(sc.hasNextInt())
{
n=sc.nextInt();
for(int i=1;i<=n;i++)
b=b.multiply(BigInteger.valueOf(i));
sss=b.toString();
for(int ii=sss.length()-1;ii>=0;ii--)
{
ttx=sss.charAt(ii)-'0';
if(ttx!=0)
{
pr.printf("%5d -> %d"+"%n",n,ttx);
break;
}
}
b=BigInteger.ONE;
}
pr.close();
}
catch(Exception e)
{
System.exit(0);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
class Main
{
public static void main (String args[]) // entry point from OS
{
Main myWork = new Main(); // create a dynamic instance
myWork.Begin(); // the true entry point
}
void Begin()
{
try
{
int n;
BigInteger b=new BigInteger("1");
Scanner sc=new Scanner(System.in);
PrintWriter pr=new PrintWriter(System.out);
String sss;int ttx;
while(sc.hasNextInt())
{
n=sc.nextInt();
for(int i=1;i<=n;i++)
b=b.multiply(BigInteger.valueOf(i));
sss=b.toString();
for(int ii=sss.length()-1;ii>=0;ii--)
{
ttx=sss.charAt(ii)-'0';
if(ttx!=0)
{
pr.printf("%5d -> %d"+"%n",n,ttx);
break;
}
}
b=BigInteger.ONE;
}
pr.close();
}
catch(Exception e)
{
System.exit(0);
}
}
}
No comments:
Post a Comment