斐波那契 (Standard IO)
来源:互联网 发布:达摩画像淘宝 编辑:程序博客网 时间:2024/06/04 01:16
Description
小明有一个数列。a[0] = a[1] = 1。a[i] = i * a[i - 1] * a[i - 2](i≥2)。小明想知道a[n]的因子个数。
Input
输入仅一个正整数n。
Output
输出a[n]的因子个数mod 1,000,000,007的值。
题解
因为F[2]的因子个数等于2的一次方, F[3]的因子个数等于3的一次方*2的一次方, F[4]的因子个数等于4的一次方*3的一次方*2的二次方, F[5]的因子个数等于5的一次方*4的一次方*3的二次方*2的三次方, F[6]的因子个数等于6的一次方*5的一次方*4的二次方*3的三次方*2的五次方, F[7]的因子个数等于7的一次方*6的一次方*5的二次方*4的三次方*3的五次方*2的八次方。 注释:不是真的乘起来,而是将指数的(数值+1)乘起来。F[3]的题意值是6,因子有4个。刚好是规律的组合个数,有零次方。我们发现那些指数就是斐波那契数列啊!!
代码
const mood=1000000007;var n:longint; boo:array [0..1000001] of boolean; a,f:array [0..1000001] of longint; ans:int64;procedure try1;var i:longint;begin f[1]:=1; f[2]:=1; for i:=3 to n do f[i]:=(f[i-1]+f[i-2]) mod mood;end;procedure main;var i,j,t:longint;begin fillchar(boo,sizeof(boo),false); fillchar(a,sizeof(a),0); for i:=2 to n do if not boo[i] then begin a[i]:=f[n-i+1]; j:=i+i; while j<=n do begin boo[j]:=true; t:=j; while t mod i=0 do begin t:=t div i; a[i]:=(a[i]+f[n-j+1]) mod mood; end; j:=j+i; end; end;end;procedure print;var i:longint;begin ans:=1; for i:=2 to n do ans:=(ans*(a[i]+1)) mod mood; write(ans);end;begin readln(n); try1; main; print;end.
1 0
- 斐波那契 (Standard IO)
- Window (Standard IO)
- Party (Standard IO)
- 1326. Window (Standard IO)
- 遥控车 (Standard IO)
- Mobile Service (Standard IO)
- 舞台设置 (Standard IO)
- 拉力赛 (Standard IO)
- 车展 (Standard IO)
- 1328. Party (Standard IO)
- 三条线 (Standard IO)
- 绕圈跑 (Standard IO)
- 餐桌 (Standard IO)
- 直角三角形 (Standard IO)
- 佳肴 (Standard IO)
- 删除 (Standard IO)
- 区间 (Standard IO)
- 佳肴 (Standard IO)
- 使用SparkSQL/DataFrame读取HBase表
- MySQL命令行中文显示乱码解决
- iOS开发零碎知识点整理
- OpenGL
- Android学习内容回顾记牢,自定义适配器(adapter)必须会
- 斐波那契 (Standard IO)
- c语言数据结构——链表常用算法
- 程序员奥运:分数分解问题
- jQuery和AJAX
- Windows下利用MySQL UDF提权
- coderforces #364 A Cards
- HDU 4438 概率 多个情况下的数学期望
- Java_包(EditPlus)
- 多线程要访问共享数据的方式