P2626 斐波那契数列(升级版)

https://www.luogu.org/problemnew/show/P2626

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;

const long long mod = pow(2,31);
int f[50],n;

int main(void)
{
f[1] = 1;
f[2] = 1;

cin >> n;

for(int i = 3;i <= n;++i)
f[i] = (f[i-1] + f[i-2])%mod;

cout << f[n] << '=';

bool x = 1;

for(int i = 2;i <= f[n];++i)
for(;f[n]%i==0;)
{
if(x)
{
x = 0;
cout << i;
}
else
cout << '*' << i;
f[n]/=i;
}

return 0;
}
本站文章除注明转载外均为原创,未经允许不要转载哇. ヾ(゚ー゚ヾ) http://chicago01.top/2019/05/14/p2626-fei-bo-na-qi-shu-lie-sheng-ji-ban/index.html
Compartir