The Priest Mathematician
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 )
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 ] ) ;
}
}
}
The Priest Mathematician的更多相关文章
- UVA 10254 十八 The Priest Mathematician
The Priest Mathematician Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- 递推+高精度+找规律 UVA 10254 The Priest Mathematician
题目传送门 /* 题意:汉诺塔问题变形,多了第四个盘子可以放前k个塔,然后n-k个是经典的汉诺塔问题,问最少操作次数 递推+高精度+找规律:f[k]表示前k放在第四个盘子,g[n-k]表示经典三个盘子 ...
- UVA10254 - The Priest Mathematician(找规律)
UVA10254 - The Priest Mathematician(找规律) 题目链接 题目大意:4根柱子的汉诺塔. 解题思路:题目里面有提示,先借助四个柱子移走k个,然后在借助三个柱子移走剩余的 ...
- UVA 10254 - The Priest Mathematician (dp | 汉诺塔 | 找规律 | 大数)
本文出自 http://blog.csdn.net/shuangde800 题目点击打开链接 题意: 汉诺塔游戏请看 百度百科 正常的汉诺塔游戏是只有3个柱子,并且如果有n个圆盘,至少需要2^n- ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- [置顶] 刘汝佳《训练指南》动态规划::Beginner (25题)解题报告汇总
本文出自 http://blog.csdn.net/shuangde800 刘汝佳<算法竞赛入门经典-训练指南>的动态规划部分的习题Beginner 打开 这个专题一共有25题,刷完 ...
随机推荐
- C#连接Oracle数据库基本类
C#用来连接oracle数据库的基本类: using System; using System.Collections.Generic; using System.Linq; using System ...
- Android应用开发基础篇(13)-----GestureDetector(手势识别)
链接地址:http://www.cnblogs.com/lknlfy/archive/2012/03/05/2381025.html 一.概述 GestureDetector是一个用于识别手势的类,这 ...
- [Swust OJ 402]--皇宫看守(树形dp)
题目链接:http://acm.swust.edu.cn/problem/402/ Time limit(ms): 5000 Memory limit(kb): 65535 Description ...
- BZOJ 4305: 数列的GCD( 数论 )
对于d, 记{ai}中是d的倍数的数的个数为c, 那么有: 直接计算即可,复杂度O(NlogN+MlogM) --------------------------------------------- ...
- openGL 旋转的图形 矩阵操作
#include <windows.h> #ifdef __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut. ...
- jbpmAPI-6
第六章流程. 6.1. What is BPMN 2.0 业务流程模型和符号(BPMN)2.0规范是OMG规范,不仅定义了一个标准的业务流程的图形化表述(如BPMN 1. x),但现在还包括执行语义定 ...
- 当x含有偶数个1,返回1,否则为0。
题目描述: /* Return 1 when x contains an even number of 1s;0 otherwise. Assume W=32 */ int even_ones(uns ...
- The process "E:\Qt\4.8.5\bin\qmake.exe" exited with code 2.(不能包含中文路径,qmake够弱智的)
打开某个项目的时候,编译出现类似的错误 21:46:44: The process "E:\Qt\4.8.5\bin\qmake.exe" exited with code 2. ...
- 在C#中调用API获取网络信息和流量
原文 在C#中调用API获取网络信息和流量 最近一项目中要求显示网络流量,而且必须使用C#. 事实上,调用 IpHlpApi.dll 的 GetIfTable API 可以轻易获得网络信息和网络流量. ...
- Dream
即使下着雨,天空依旧明亮,因为远方有我的梦想. ——forever97