HDOJ/HDU 1250 Hat's Fibonacci(大数~斐波拉契)

Problem Description
A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.

Input
Each line will contain an integers. Process to end of file.

Output
For each case, output the result in a line.

Sample Input
100

Sample Output
4203968145672990846840663646

Note:
No generated Fibonacci number in excess of 2005 digits will be in the test data, ie. F(20) = 66526 has 5 digits.

就是根据这个公式:
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)

输入一个n,输出f(n)的值。

注意,这是大数~答案的位数高达2005位~~~

再一次体会Java大数的强大吧~

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static BigInteger f[] = new BigInteger[7045];
    public static void main(String[] args) {
        dabiao();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n =sc.nextInt();
            System.out.println(f[n]);
            //System.out.println("---------");
            //System.out.println(f[n].toString().length());
            //开数组~看开到多少位的时候,位数大于2005
        }
    }
    private static void dabiao() {
        f[1]=new BigInteger("1");
        f[2]=new BigInteger("1");
        f[3]=new BigInteger("1");
        f[4]=new BigInteger("1");
        for(int i=5;i<f.length;i++){
            f[i]=f[i-1].add(f[i-2]).add(f[i-3]).add(f[i-4]);
        }
    }
}
OpenClaw 在 Docker 容器中的部署实战——零配置启动 本文介绍了OpenClaw在Docker容器中的快速部署方法,对比了本地部署与容器化部署的优势。通过官方镜像和Docker Compose两种方式,5分钟即可完成部署,并详细讲解了配置管理方案(挂载配置文件和环境变量)。文章还提供了飞书集成配置方法,以及生产环境下的日志管理、资源限制、健康检查等优化建议。最后包含常见问题排查指南,帮助开发者快速实现OpenClaw的容器化部署。 阅读详情

相关推荐

使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第七讲)

默认是第一种键盘模式,当需要切换模式,进入到ta_event_cb函数修改模式,下面代码以数字模式举例子lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);在该界面中可以设置键盘文字的大小和文本类型,最下方判断键盘是否支持中文输入(中文输入,当汉字库不够大时,用户点击中文输入会少很多字)。//当LV_USE_KEYBOARD为1时启用虚拟键盘,LV_USE_ZH_KEYBOARD为1时支持中文输入。随后在系统设置界面中点击项目选项,选择显示键盘。

weixin_38828382的博客 1427

HDU 1250 很麻烦的题(大数相加)

Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F...

zhe 271

Livox MID360与Fast-LIO2的实战部署指南:从驱动安装到点云处理

本文提供Livox MID360激光雷达与Fast-LIO2激光惯性里程计从零开始的实战部署指南。详细介绍了Ubuntu系统下的驱动安装、网络配置、点云数据验证以及Fast-LIO2算法的编译、参数配置与联合启动流程,帮助开发者快速搭建移动机器人SLAM系统,并包含关键参数调优与常见故障排查方法。

java5的博客 1040

1.28题目翻译

题目链接:https://acs.jxnu.edu.cn/problem/HDU1250 描述: A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F

weixin_61393233的博客 264

自然语言处理:稀疏向量表示

稀疏向量表示是指运用特定的方法和技术,将数据(如文本、图像、信号等)转化为向量形式,且该向量具有大部分元素值为零,仅少数元素值非零的特征,以此来实现对数据的高效存储、处理和分析。

老赵爱学习的博客 1452

三代测序选型指南:PacBio HiFi vs Nanopore vs Illumina技术对比与适用场景

本文深入对比了三代测序技术PacBio HiFi、Nanopore与Illumina的核心参数、成本模型和应用场景,为生物信息学研究提供选型指南。通过实测数据和技术组合策略分析,帮助实验室根据研究需求选择最适合的测序方案,涵盖基因组组装、表观遗传学等关键应用领域。

fern8的博客 933

大数运算的算法

在数学运算的过程中 ,经常碰到这样的问题:参与运算的 数字很大或者对运算结果的精度要求很高。无论何种计算机 语言 ,在描述数据类型时都有一定的精度和位数要求 ,比如说 16 位整型数 (int) 所能表示的范围为 - 32768~32767 ,实数 (float)所能表示的精度为小数点后 8 位等 ,每种类型的数据都 有其精度和位数限制。超过 20 位有效数字的数值一般就无 法表示了。所以 ,在上

我的ACM 1万+

史上最全的Logisim存储系统实验教程(基于华中科技大学计算机组成原理实验)内赋源码下载

本博客是最全的最好的解释的华中科技大学计算机组成实验存储系统实验,本博客给出了电路实现,也给出了使用电路的原因有利于新手学习十分详细。并且内赋源码下载。

qq_62325622的博客 2万+

ZCMU 1041: 二哥的困惑 Ⅳ(大数斐波那契数列)

1041: 二哥的困惑 Ⅳ Description A Fibonacci sequence is calculated by adding the previous two members of the sequence, with the first two members being both 1. f(1) = 1, f(2) = 1, f(n > 2) = f(n - 1) + f...

weixin_44941429的博客 470

智驾车载以太网(18)-switch之报文转发和vlan处理流程

本文详细解析了交换机中报文处理和转发流程:1)通过目标MAC查找转发端口,源MAC创建ARL条目;2)VLAN标签处理包括tagged/untagged帧判断、默认VID标记等5种处理方式;3)完整转发流程包含CRC校验、IQ封装、VLAN和ARL表查询、端口向量计算及优先级队列发送。文中还涉及TCAM修改VLAN、802.1q多种模式处理等细节,省略了流量控制等次要流程。该过程实现了基于MAC和VLAN的高效二层交换。

mitugaoyang1993的博客 49

【灰度共生矩阵(GLCM)原理及代码实现】

文章主旨详细介绍灰度共生矩阵(Gray-Level Co-occurrence Matrix, GLCM)的生成原理、核心特征量及其在图像纹理分析中的应用,并提供了可运行的Python代码实现。该网页是一篇理论结合实践的优秀技术文章。它不仅清晰地解释了GLCM这一经典纹理分析工具背后的数学原理,还提供了完整、可复现的代码,非常适合计算机视觉或图像处理领域的学习者和开发者入门并实践灰度共生矩阵。读者可以通过运行代码来直观理解GLCM如何工作,并提取图像的纹理特征。

blotemj.blog.csdn.net 185

Hat's Fibonacci

Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4997    Accepted Submission(s): 1690 Problem Description A Fibonacci se

wenlovingliu的专栏 610

Unity-TextMeshPro如何扩展材质实现字体Face+Outline流光效果

前言 TexeMeshPro 是Unity的一个Text文本插件,实现了比UGUI的Text,更好看的效果,跟高效的性能,所以深受大家的喜欢,但是再好的插件,也不是万能的,比如我们的策划有个新需求,要我们的VIP的名字比普通玩家有更好看的效果,例如:字体流光,外发光颜色扰动,字体贴图等等。那我们就需要去扩展TextMeshPRo的shader功能了。如下图所示 本文,我就带大家一起来扩展一下:如何扩展TextMeshProUGUI TextMesh原始面板 扩展功能后的面板 扩展TextMeshPro

TxNet 9701

HDU-A Fibonacci sequence斐波那契数列-大数求和

问题及代码: /* *Copyright (c)2014,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:Fibonacci.cpp *作 者:单昕昕 *完成日期:2015年2月3日 *版 本 号:v1.0 * *问题描述:A Fibonacci sequence is calculated by adding the previous

Some. 1457

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HDU 1250 Hat's Fibonacci

Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9821    Accepted Submission(s): 3260 Problem Description A Fibonacc

L-75的专栏 470

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDU-1250 Hat‘s Fibonacci(高精度递加, 大斐波那契数)

A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4) Your task is to take a number as input, and

qq_45900103的博客 246

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

zoj-4108 Fibonacci in the Pocket(斐波那契数列奇偶性规律+Java大数)

Fibonacci in the Pocket Time Limit: 1 Second Memory Limit: 65536 KB DreamGrid has just found a Fibonacci sequence and two integers and in his right pocket, where indicates the -th element in ...

FreeGo~ 941

很麻煩的題

A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-

wanghandou的博客 291

STM32H743ZI与IIM-42652实现6DoF姿态检测开发指南

惯性测量单元(IMU)是运动追踪和姿态检测的核心传感器,通过融合3轴加速度计和3轴陀螺仪数据实现6自由度(6DoF)测量。IIM-42652作为高性能6轴IMU芯片,配合STM32H743ZI微控制器可构建实时运动处理系统。该系统采用SPI接口通信,利用DMA传输和互补滤波算法,能有效处理传感器数据并解算欧拉角。在无人机飞控、工业机器人和VR/AR设备等场景中,这种硬件组合提供了高精度姿态检测方案,其中FIFO缓冲和温度补偿技术显著提升了系统可靠性。

weixin_30629653的博客 374

zoj1828||joj1949 解题报告

<br /> Fibonacci NumbersTime Limit: 1 Second      Memory Limit: 32768 KB <br />A Fibonacci sequence is calculated by adding the previous two members of the sequence, with the first two members being both 1.<br />f(1) = 1, f(2) = 1, f(n > 2) = f(n - 1) + f

neoxuhaotian的专栏 1651

hdu 1250 Hat&#39;s Fibonacci

点击此处即可传送hdu 1250 Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) ...

weixin_34310785的博客 158

hdu 1250 java大数练习

Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n -

wtml 343

【JAVA大数】Hat's Fibonacci HDU - 1250

题目链接 Hat’s Fibonacci HDU - 1250 题目 A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) =...

EnjoyingAC的博客 208

大数变形版斐波那契

A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3)

南风古 550

hdu 1250 高精度+类似斐波那契数列

http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7245    Accepted Submissi

ACM,再见! 1208

Hat's Fibonacci

Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>...

weixin_34381666的博客 171
0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值