P2626 斐波那契数列(升级版) 洛谷(2626)
https://www.luogu.org/problem/show?pid=2626
题目背景
大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ 2 且 n 为整数)。
题目描述
请你求出第n个斐波那契数列的数mod(或%)2^31之后的值。并把它分解质因数。
输入输出格式
输入格式:
n
输出格式:
把第n个斐波那契数列的数分解质因数。
输入输出样例
5
5=5
6
8=2*2*2
说明
n<=48
#include <algorithm>
#include <iostream>
#include <cmath> const long long mod=pow(,); using namespace std; long long x,num=,cnt,n; int main()
{
cin>>n;
double x=sqrt(5.0);
cnt=/x*((pow((+x)/,n)-(pow((-x)/,n))));
cnt%=mod;
long long zz=cnt;
cout<<cnt<<'=';
while(cnt!=)
{
while(cnt%num==)
{
if(cnt<zz) cout<<'*'<<num;
else cout<<num;
cnt/=num;
}
num++;
}
return ;
}
P2626 斐波那契数列(升级版) 洛谷(2626)的更多相关文章
- 洛谷——P2626 斐波那契数列(升级版)
P2626 斐波那契数列(升级版) 题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ ...
- 洛谷——P2626 斐波那契数列(升级版)矩阵
题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ 2 且 n 为整数). 题目描述 ...
- 洛谷 P2626 斐波那契数列(升级版)
题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ 2 且 n 为整数). 题目描述 ...
- [洛谷P2626]斐波那契数列(升级版)
题目大意:请你求出第$n$个斐波那契数列的数$mod 2^{31}$之后的值.并把它分解质因数. 题解:乱搞 卡点:1.忘记取模 C++ Code: #include<cstdio> #i ...
- [NOIP1997] P2626 斐波那契数列(升级版)
题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ 2 且 n 为整数). 题目描述 ...
- P2626 斐波那契数列(升级版)(合数的质数分解, 大数为素数的概率十分小的利用)
题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: f(1)=1f(1) = 1 f(1)=1 f(2)=1f(2) = 1f(2)=1 f(n)=f(n−1)+f(n−2)f(n) = f ...
- P2626 斐波那契数列(升级版)
题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ 2 且 n 为整数). 题目描述 ...
- AC日记——斐波那契数列(升级版) 洛谷 P2626
斐波那契数列(升级版) 思路: 水题: 代码: #include <cmath> #include <cstdio> #include <cstring> #inc ...
- 斐波那契数列的通项公式x+洛谷P2626x
#include<cstdio> #include<iostream> #include<cmath> using namespace std; int main( ...
随机推荐
- zabbix详细介绍及其自动动态发现
zabbix3.2.1 第1章 安装 1.1 查看系统环境 [root@centos7-2 ~]# [root@centos7-2 ~]# hostname -I 10.0.0.10 172.16.1 ...
- [C陷阱和缺陷] 第7章 可移植性缺陷
C语言在许多不同的系统平台上都有实现.的确,使用C语言编写程序的一个首要原因就是,C程序能够方便地在不同的编程环境中移植. 不同的系统有不同的需求,因此我们应该能够预料到,机器不同则其上的C语 ...
- CF817A Treasure Hunt
思路: 起点(x1, y1),终点(x2, y2),步长(dx, -dy),(dx, dy),(-dx, -dy),(-dx, dy).只要满足abs(x1 - x2) % dx == 0 并且 ab ...
- Java易忘知识点统计
缺少 内容 替代措施 幂运算 借助Math类的pow方法 注意 内容 备注 const Java保留关键字,未使用 其他 强制类型转换时,若要舍入得到最接近的整数,可以使用Math.round方法 J ...
- Python操作远程数据库
我的项目要往数据库中插入create_time和update_time,那就势必要引用现在的系统时间,经过大量的查找,终于发现往python是没有对应时间datetime的相关通配符的,那么我们要怎么 ...
- C++为什么抓不到除0错“异常”?
http://blog.csdn.net/nanyu/article/details/6475555 有人问这个问题: try { std::cout << 10/0 << s ...
- redis的安装和使用【2】redis的java操作
修改redis.conf# 配置绑定ip,作者机子为192.168.100.192,请读者根据实际情况设置bind 192.168.100.192#非保护模式protected-mode no保存重启 ...
- C# 字符串每隔两个 提取
private void button3_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); str ...
- java_IO_1
public class DirStudy { public static void main(String[] args) { File file = new File("F:/Eclip ...
- js实现字符串反转
方案1: var str = "abcdef"; console.log( str.split("").reverse().join("") ...