题意:

  求不大于4000000的斐波那契数列中,所有偶数之和.

SOL:

  还是只会暴模...看讨论区貌似有一个很牛逼的大神的发言?

  英语水平太差...

  mark以下

The Fibonacci sequence is a driven by the second order linear difference equation Fn+2 = Fn+1 + Fn, with boundary conditions F1 = 1, F2 = 1, and thus can be solved exactly. As we know from practice that Fn is roughly exponential, we try Fn = Aa^n for A and a constants. This gives the quadratic a^2 = a + 1, which happens to be the equation for the golden ratio Φ, and its inverse which I'll denote Φ' (i.e. Φ' = 1/Φ, Φ' = Φ - 1) As the equation is second order then it is a linear combination of these two solutions and the boundary conditions define the constants involved, i.e. Fn = AΦ^n + BΦ'^n F0 = 0 (easy if you follow backwards) so A + B = 0 F1 = 1 . Using Φ = (1 + r)/2 and Φ' = (1 - r)/2 where r is the positive square root of 5, you can find A - B = 2/r yielding A = 1/r, B = -1/r So Fn = (Φ^n /r) - (Φ'^n /r) = (Φ^n - Φ'^n)/r for all n. As can be seen, the even terms are when n is a multiple of 3, so using this formula add F3 + F6 + ... until you get a term greater than one million. Thus a program for this could be only a handful of lines long. A slightly further simplification would be to work out Φ^3 and Φ'^3, call them b and b' respectively. Then F3k = (b^k - b'^k)/r for k = 1,2,3...

PE-2 & 暴模...的更多相关文章

  1. PE-1 & 暴模|容斥

    题意: 求1000以下3或5的倍数之和. SOL: 暴模也是兹瓷的啊... 那么就想到了初赛悲催的滚粗...容斥忘了加上多减的数了... 然后对着题...T = 3*333*(1+333)/2 + 5 ...

  2. PE的一些水 3-50

    T3: 分解质因数. lalala T4: 暴模. 然而数学方法怎么搞?---->也就是怎么手算?... 于是看了一下讨论区...发现原来我的数学已经低于小学生水平了... 我们把答案abccb ...

  3. 【旧文章搬运】暴搜内存查找PE镜像

    原文发表于百度空间,2008-7-28========================================================================== 前面介绍了修 ...

  4. hiho一下 第九十七周 数论六·模线性方程组

    题目1 : 数论六·模线性方程组 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:今天我听到一个挺有意思的故事! 小Hi:什么故事啊? 小Ho:说秦末,刘邦的将军 ...

  5. PE结构详解

    1 基本概念 下表描述了贯穿于本文中的一些概念: 名称 描述 地址 是“虚拟地址”而不是“物理地址”.为什么不是“物理地址”呢?因为数据在内存的位置经常在变,这样可以节省内存开支.避开错误的内存位置等 ...

  6. HDU - 6185 Covering(暴搜+递推+矩阵快速幂)

    Covering Bob's school has a big playground, boys and girls always play games here after school. To p ...

  7. NOIP2018提高组省一冲奖班模测训练(一)

    比赛链接 https://www.51nod.com/contest/problemList.html#!contestId=72&randomCode=147206 这次考试的题非常有质量 ...

  8. POJ 3188暴搜

    题意: 思路: 裸的暴搜 --. 但是要注意如果你不用所有的按键就能输出最优解的话一定要把所有的字母都安排到一个位置-. 我的一群PE就是这么来的-- 为什么写的人这么少-- // by Sirius ...

  9. HDU 4704 Sum 超大数幂取模

    很容易得出答案就是2^(n-1) 但是N暴大,所以不可以直接用幂取模,因为除法操作至少O(len)了,总时间会达到O(len*log(N)) 显然爆的一塌糊涂 套用FZU1759的模板+顺手写一个大数 ...

随机推荐

  1. 三、jQuery--jQuery基础--jQuery基础课程--第6章 jQuery 事件与应用

    1.页面加载时触发ready()事件 ready()事件类似于onLoad()事件,但前者只要页面的DOM结构加载后便触发,而后者必须在页面全部元素加载成功才触发,ready()可以写多个,按顺序执行 ...

  2. php JS和JQ

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. .net学习笔记---xml操作及读写

    一.XML文件操作中与.Net中对应的类 微软的.NET框架在System.xml命名空间提供了一系列的类用于Dom的实现. 以下给出XML文档的组成部分对应.NET中的类: XML文档组成部分 对应 ...

  4. jquery学习笔记---闭包,原型链,this关键字

    网上的资料很多,关于闭包,原型链,面向对象之内的.本人也有一点自己的总结. 关于this: this 的值取决于 function 被调用的方式,一共有四种, 如果一个 function 是一个对象的 ...

  5. 15.命令模式(Command Pattern)

    using System; namespace ConsoleApplication8 { class Program { /// <summary> /// 在软件系统中,“行为请求者” ...

  6. 微信token验证失败的解决方法

    一.问题由来 在使用URL和Token启用微信公众平台开发模式消息接口的时候,我们会碰到下面三种情况 1. token校验失败 这样回头检查一下各项配置是否正确.如果确定配置没有问题,请按下面的方法检 ...

  7. .NET MVC4 数据验证Model(二)

      一.概述 MVC分为ViewModel.Control.View,对数据的封装MVC做的很好,确实是不错的WEB框架,针对MVC的ViewModel封装的也是相当的不错,最近做一个MVC的项目,采 ...

  8. [UI]实用案例--Shape绘制实用圆圈

    Android允许通过xml定义资源,常见的事string,id,integer,dimen等,也可以定义一些图片资源,比如用来做几何的矢量图就非常好用,其中有许多的细节问题,具体需求可以再结合goo ...

  9. 一个json字符串

    { "area": [{ "flag": "Y", "ishot": "N", "lag& ...

  10. 读取csv文件

    String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\test\\;Extended Pr ...