标签:
mport java.util.Scanner; public class Main { public static double solution( int n ) { double ret = 0; for( int i = 2; i <= n; i++ ) { ret += temp( n, i ) * ( i - 1 ); } return ret; } public static double temp( int n, int k ) { double m = 1; double t1 = n; for( int i = k; i > 0; i-- ) { m *= t1; t1--; } double o = 1; for( int i = k; i > 1; i-- ) { o *= i; } return ( m / o ); } public static void main( String[] args ) { // TODO Auto-generated method stub Scanner sc = new Scanner( System.in ); while( sc.hasNext() ) { int n = sc.nextInt(); System.out.println((long)Main.solution( n ) ); } } }
标签:
原文地址:http://www.cnblogs.com/dick159/p/5085651.html