hdu 6222 Heron and His Triangle
来源:互联网 发布:2017暑运大数据报告 编辑:程序博客网 时间:2024/06/06 01:18
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6222
解析:规律:a[n] = 4*a[n-1] - a[n-2]
代码:
import java.io.*;import java.math.BigInteger;import java.util.*;public class Main { public static Scanner s = new Scanner(System.in); public static void main(String args[]) throws Exception { int t; t = s.nextInt(); while(t-- != 0) { BigInteger x = s.nextBigInteger(); BigInteger p = new BigInteger("4"), pp = new BigInteger("2"), k = new BigInteger("4"); BigInteger now = p; while(now.compareTo(x) < 0) { now = p.multiply(k).subtract(pp); pp = p; p = now; } System.out.println(now); } }}
阅读全文
0 0
- hdu 6222 Heron and His Triangle
- Heron and His Triangle(HDU 6222 找规律+大数)
- 【HDU 6222 2017ACM/ICPC亚洲区沈阳站】Heron and His Triangle
- Heron and His Triangle 规律+java大整数
- 2017沈阳站现场赛打表程序 F Heron and his Triange
- HDU - 5410 CRB and His Birthday
- HDU 5410 CRB and His Birthday
- hdu acm 5410 CRB and His Birthday
- HDU 5654 xiaoxin and his watermelon candy
- HDU 5654 xiaoxin and his watermelon candy
- HDU 5410 CRB and His Birthday
- CRB and His Birthday(HDU-5410)
- HDU 5410 CRB and His Birthday
- Storm and Heron
- Sticks and Right Triangle HDU
- HDU 5410 CRB and His Birthday(DP)
- HDU 5410 CRB and His Birthday(DP)
- hdu 5410 CRB and His Birthday(背包)
- C语言指针与数组的问题--初级
- UDP发送大型文件_不丢包
- OpenStack Anchor项目介绍
- matplotlib函数库使用scatter绘制散点图
- 浅析可变参数列表及实例分析
- hdu 6222 Heron and His Triangle
- LintCode 最大子数组(dp)
- 类抽象类接口_练习
- paxos算法部分总结
- 关于使用SQL Server LocalDB 一点体会
- hdu 5775 线段树
- linux解压
- eclipse创建maven web项目更改servlet版本小技巧
- 经验总结-完整介绍Android Studio中Git的使用之git的基本准备及提交代码到本地(一)-2