Twice Equation
题目链接: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的更多相关文章
- CodeForces460B. Little Dima and Equation
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...
- ACM: FZU 2102 Solve equation - 手速题
FZU 2102 Solve equation Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- HDU 5937 Equation
题意: 有1~9数字各有a1, a2, -, a9个, 有无穷多的+和=. 问只用这些数字, 最多能组成多少个不同的等式x+y=z, 其中x,y,z∈[1,9]. 等式中只要有一个数字不一样 就是不一 ...
- coursera机器学习笔记-多元线性回归,normal equation
#对coursera上Andrew Ng老师开的机器学习课程的笔记和心得: #注:此笔记是我自己认为本节课里比较重要.难理解或容易忘记的内容并做了些补充,并非是课堂详细笔记和要点: #标记为<补 ...
- CF460B Little Dima and Equation (水题?
Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit ...
- Linear regression with multiple variables(多特征的线型回归)算法实例_梯度下降解法(Gradient DesentMulti)以及正规方程解法(Normal Equation)
,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, , ...
- 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 ...
- [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 ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- SGU 106 The equation
H - The equation Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Subm ...
随机推荐
- Canvas入门02-绘制直线
主要使用的API有: context.moveTo(x,y) 声明线的起始坐标 context.lineTo(x,y) 声明线的下一个坐标 context.fillStyle 声明线的填充颜色 co ...
- python+selenium下载文件——firefox
修改Firefox的相关配置. 1.profile.set_preference('browser.download.folderList',2) 设置成0代表桌面,1代表下载到浏览器默认下载路径:2 ...
- 【监控笔记】【1.3】监控事件系列——SQL Trace(黑盒跟踪 BlackBox Trace)
[1]它跟踪了哪些事件? (1.1)存储过程执行(SP:Strating) (1.2)T-SQL执行(SQL:BatchString) (1.3)错误和警告(Exception,Attention) ...
- windows上Appium安装和使用
1.Appium安装相关依赖工具: Android Studio或者Android SDK:https://developer.android.com/studio/Appium Desktop: h ...
- Python 入门之 模块
Python 入门之 模块 1.模块 (1)模块是什么? 将一些常用的功能封装到一个文件中,那么这个存储着很多常用的功能的py文件,就是模块. 模块就是文件,存放一堆常用的函数.模块,就是一些常用 ...
- A - 卿学姐与公主(线段树+单点更新+区间极值)
A - 卿学姐与公主 Time Limit: 2000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- django中配置MySql
1.配置字段 在setting文件中配置数据库字段:数据库需要提前手动创建好:语句(create database testdb charset "utf8";) DATABASE ...
- 为ASP.NET按钮(Button)添加确认对话框
http://www.cnblogs.com/blodfox777/articles/1261303.html Button有两个点击事件: onclick 触发服务端事件,脚本为c#或VB.NET ...
- elementUI 等 UI框架中,@change方法传递参数
有些业务中,在使用 @change 回调的时候需要动态获取当前循环下的特定值,但是@change方法一旦传递参数就会覆盖原本的数据,对此,有两种方法解决: // 这种方法据说会改变 this 指向 ...
- 【学习总结】快速上手Linux玩转典型应用-第3章-CentOS的安装
课程目录链接 快速上手Linux玩转典型应用-目录 目录 1. 虚拟机是什么 2. 在虚拟机中安装CentOS 3. 云服务器介绍 ================================== ...