The Priest Mathematician
2013-09-12 17:21
197 查看
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31329#problem/F
f[0] = 1 , f[ i ] = f[ i - 1 ] + 2 ^( n - k - 2 )
f[0] = 1 , f[ i ] = f[ i - 1 ] + 2 ^( n - k - 2 )
import java.util.Scanner; import java.math.BigInteger ; public class Main { public static void main(String[] args ) { Scanner cin = new Scanner( System.in ); BigInteger[] f = new BigInteger[ 10005 ] ; int k = 1 , cnt = 0 ; f[ 0 ] = new BigInteger( "0" ) ; BigInteger d = new BigInteger( "1" ) ; for( int i = 1; i <= 10004 ; ++i ) { f[ i ] = f[ i - 1 ].add( d ) ; cnt++; if( cnt == k ) { cnt = 0 ; k++; d = d.multiply(BigInteger.valueOf(2) ) ; } } while( cin.hasNext()) { int n = cin.nextInt(); System.out.println( f[ n ] ) ; } } }
相关文章推荐
- UVa Problem 10254 The Priest Mathematician (牧师数学家)
- uva 10254 - The Priest Mathematician(dp)
- UVa Problem Solution: 10254 - The Priest Mathematician
- UVA 10254 - The Priest Mathematician (dp | 汉诺塔 | 找规律 | 大数)
- uva 10254 - The Priest Mathematician
- UVA 10254 - The Priest Mathematician(规律)
- UVA 10254 - The Priest Mathematician (dp | 汉诺塔 | 找规律 | 大数)
- 递推+高精度+找规律 UVA 10254 The Priest Mathematician
- UVA 10254 The Priest Mathematician
- uva 10254 the priest mathematician
- UVA 10254 The Priest Mathematician
- uva 10254——The Priest Mathematician
- UVa 10254 - The Priest Mathematician (4柱汉诺塔)
- UVA 10254-The Priest Mathematician(大数+递推)
- The Priest Mathematician
- UVA10254 - The Priest Mathematician(找规律)
- uva 10254 The Priest Mathematician
- UVA 10254 十八 The Priest Mathematician
- Vasya is the beginning mathematician. He decided to make an important contribution to the science an
- [FOJ][2042][The Mad Mathematician][数位dp]