How Many Fibs_hdu_1316(大数).java
How Many Fibs?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3098 Accepted Submission(s): 1232
f1 := 1
f2 := 2
fn := fn-1 + fn-2 (n >= 3)
Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b].
1234567890 9876543210
0 0
4
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
BigInteger f[]=new BigInteger[505];
f[0]=BigInteger.valueOf(1);
f[1]=BigInteger.valueOf(2);
for(int i=2;i<502;i++){
f[i]=f[i-1].add(f[i-2]);
}
while(true){
BigInteger a=input.nextBigInteger();
BigInteger b=input.nextBigInteger();
if(a.equals(BigInteger.ZERO)&&b.equals(BigInteger.ZERO))
break;
int sum=0;
for(int i=0;i<502&&b.compareTo(f[i])>=0;i++){
if(f[i].compareTo(a)>=0)
sum++;
}
System.out.println(sum);
}
}
}
How Many Fibs_hdu_1316(大数).java的更多相关文章
- HDU 1715 大数java
大菲波数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU1134/HDU1133 递推 大数 java
Game of Connections Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- HDU1063 大数 java
Exponentiation Time Limit: 2000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Integer Inquiry_hdu_1047(大数).java
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 大数java(pow)
Problems involving the computation of exact values of very large magnitude and precision are common. ...
- java求两个数中的大数
java求两个数中的大数 java中的max函数在Math中 应用如下: int a=34: int b=45: int ans=Math.max(34,45); 那么ans的值就是45.
- CF1245 A. Good ol' Numbers Coloring(java与gcd)
题意:给定数字A和数字B,问是否满足gcd(A,B)==1. 思路:可以直接写函数gcd.也可以用大数自带的gcd功能. 代码1: /* @author nimphy @create 2019-11- ...
- HDU 5686:2016"百度之星" - 资格赛 Problem B
原文链接:https://www.dreamwings.cn/hdu5686/2645.html Problem B Time Limit: 2000/1000 MS (Java/Others) ...
- 2016百度之星资格赛 Round1(2,3,4题)
Problem B Accepts: 2515 Submissions: 9216 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
随机推荐
- 使用NSURLSession实现断点续传
在sb中创建按钮,并且连线到.m文件中
- MySQL性能调优与架构设计-架构篇
架构篇(1) 读书笔记 1.Scale(扩展):从数据库来看,就是让数据库能够提供更强的服务能力 ScaleOut: 是通过增加处理节点的方式来提高整体处理能力 ScaleUp: 是通过增加当前处理节 ...
- Android自定义属性时format选项可以取用的值
1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name="名称"> <attr format=" ...
- platform_driver与file_operations两种方法开发led驱动
下面是两个LED灯的驱动程序 一个用platform_driver 另一个用file_operations #include <linux/kernel.h> #include <l ...
- 【 D3.js 选择集与数据详解 — 4 】 enter和exit的处理方法以及处理模板
绑定数据之后,选择集分为三部分:update.enter.exit.这三部分的处理办法是什么呢?本文将讲解其处理方法,以及一个常用的处理模板. 1. enter的处理方法 如果没有足够的元素,那么处理 ...
- Xcode工程中全局搜索汉字的方法
打开”Find Navigator” 切换搜索模式到 “Find > Regular Expression” 输入@"[^"]*[\u4E00-\u9FA5]+[^" ...
- 一行代码搞定Adapter
15年Google I/O大会发不了三个重要支持库 >Material design (Android Support Design) >百分比布局:Percent support lib ...
- CORREL
CORREL Show All Returns the correlation coefficient of the array1 and array2 cell ranges. Use the co ...
- Unity3D Mathf函数
Mathf.Abs绝对值 计算并返回指定参数 f 绝对值. Mathf.Acos反余弦 static function Acos (f : float) : float 以弧度为单位计算并返回参数 f ...
- 【JS】Intermediate3:AJAX
1.load new content into a page without a full reload XML HTTP Request (XHR) To retrieve new content ...