题目链接:https://nanti.jisuanke.com/t/A1541

题意:给你一个L,要你求一个不小于L的最小数字n,对于一个整数m,满足2*(m+1)*m=n*(n+1)。

思路:打表找规律:打了一个

3
20
119
696
4059
23660
137903
803760
4684659
27304196

最后找到规律f(n)=6f(n-1)-f(n-2)+2;用Java大数打表求得。

public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int T=cin.nextInt();
BigInteger[] f=new BigInteger [1500];
BigInteger two=new BigInteger("2");
BigInteger six=new BigInteger("6");
BigInteger L;
f[1]=new BigInteger("3");f
[2]=new BigInteger("20");
for(int i=3;i<=1200;i++) {
f[i]=f[i-1].multiply(six).subtract(f[i-2]).add(two);
}
for(int i=0;i<T;i++) {
L=cin.nextBigInteger();
for(int j=1;j<=1200;j++) {
if(L.compareTo(f[j])<=0) {
System.out.println(f[j]);
break;
}
}
}
}
}

Twice Equation的更多相关文章

  1. CodeForces460B. Little Dima and Equation

    B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. ACM: FZU 2102 Solve equation - 手速题

     FZU 2102   Solve equation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

  3. HDU 5937 Equation

    题意: 有1~9数字各有a1, a2, -, a9个, 有无穷多的+和=. 问只用这些数字, 最多能组成多少个不同的等式x+y=z, 其中x,y,z∈[1,9]. 等式中只要有一个数字不一样 就是不一 ...

  4. coursera机器学习笔记-多元线性回归,normal equation

    #对coursera上Andrew Ng老师开的机器学习课程的笔记和心得: #注:此笔记是我自己认为本节课里比较重要.难理解或容易忘记的内容并做了些补充,并非是课堂详细笔记和要点: #标记为<补 ...

  5. CF460B Little Dima and Equation (水题?

    Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit ...

  6. Linear regression with multiple variables(多特征的线型回归)算法实例_梯度下降解法(Gradient DesentMulti)以及正规方程解法(Normal Equation)

    ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, , ...

  7. ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分

    Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...

  8. [ACM_数学] Counting Solutions to an Integral Equation (x+2y+2z=n 组合种类)

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27938#problem/E 题目大意:Given, n, count the numbe ...

  9. hdu 2199 Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  10. SGU 106 The equation

    H - The equation Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Subm ...

随机推荐

  1. window 下python2.7与python3.5两版本共存设置

    分别下载两个版本的Python,安装. (1)在Path环境变量中检查以下4个变量(Path中的环境变量是以分号隔开的): 1.c:\Python27 2.c:\Python27\Scripts 3. ...

  2. 深入理解Linux-hostname

    当我觉得对Linux系统下修改hostname已经非常熟悉的时候,今天碰到了几个个问题,这几个问题给我好好上了一课,很多知识点,当你觉得你已经掌握的时候,其实你了解的还只是皮毛.技术活,切勿浅尝则止! ...

  3. Python--笔试题

    一.如何提高Python的运行效率: 1.使用生成器,因为可以节约大量内存 2.循环代码优化,避免过多重复代码的执行 3.核心模块用Cython PyPy等,提高效率 4.多进程.多线程.协程 5.多 ...

  4. kubernetes快速应用入门

    kubectl 就是 api server的客户端工具 创建一个nginx的pod [root@master ~]# kubectl run nginx-deploy --image=nginx:1. ...

  5. linux中文件属性

    一. linux系统如何管理文件 1.1. 硬盘中的静态文件和inode a. 文件平时都在存放在硬盘中的,硬盘中存储的文件以一种固定的形式存放的,我们叫静态文件. b. 一块硬盘中可以分为两大区域: ...

  6. Period II

    For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the ...

  7. docker环境下分析zookeeper观察者角色

    问题引入 zookeeper新引入的角色observer是不参与投票的,通过增加observer节点,可以在提高zk系统读吞吐量时,不影响写吞吐量. 那么问题来了 Zookeeper系统节点如果超过半 ...

  8. unsolved question's solution

    因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了 $luogu:$ P1973 [NOI2011]Noi嘉年华: 时间离散化,预处理一个区间$[l,r]$内的最多活动个数$in[l] ...

  9. 【转】MySQL my.cnf 参数 详解

    [client] port    = 3306    //客户端端口号为3306 socket  = /tmp/mysql.sock  //套接字文件(sockets),这种文件一般用在网络上的资料套 ...

  10. 使用 VS Code 搭建 TypeScript 开发环境

    使用 VS Code 搭建 TypeScript 开发环境 TypeScript 是 JavaScript 的超集,TypeScript 只是增强了 JavaScript 而非改变了 JavaScri ...