/************************************************************** Problem: 1263 User: syh0313 Language: Java Result: Accepted Time:1180 ms Memory:22588 kb ****************************************************************/ import java.math.BigInteger; import java.util.Scanner; public class Main { public static BigInteger po(BigInteger a, int b) { if (b== 0 ) return BigInteger.valueOf( 1 ); if (b== 1 ) return a; BigInteger c=po(a,b/ 2 ); if (b% 2 == 1 ) return c.multiply(c.multiply(a)); else return c.multiply(c); } public static void main(String[] args) { Scanner cin= new Scanner(System.in); int n,num= 0 ; boolean [] f= new boolean [ 100010 ]; BigInteger[] a= new BigInteger[ 15010 ]; n=cin.nextInt(); BigInteger ans=BigInteger.valueOf(n); for ( int i=Math.max(n/ 3 - 10 , 2 );i<=Math.min(n/ 3 + 10 ,n);i++) { int k=n/i; int now=n-k*i; BigInteger nn=po(BigInteger.valueOf(k+ 1 ),now); nn=nn.multiply(po(BigInteger.valueOf(k),i-now)); if (ans.compareTo(nn)==- 1 ) ans=nn; } BigInteger kk=ans; while (kk.compareTo(BigInteger.valueOf( 0 ))!= 0 ) { a[++num]=kk.mod(BigInteger.valueOf( 10 )); kk=kk.divide(BigInteger.valueOf( 10 )); } System.out.println(num); for ( int i=num;i>=Math.max( 1 ,num- 99 );i--) System.out.print(a[i]); } } |