51nod 1355 斐波那契的最小公倍數

2021-08-03 03:58:25 字數 992 閱讀 3255

斐波那契數列定義如下:

f(0) = 0 f(1) = 1

f(n) = f(n-1) + f(n-2)

給出n個正整數a1, a2,...... an,求對應的斐波那契數的最小公倍數,由於數字很大,輸出mod 1000000007的結果即可。

例如:1 3 6 9, 對應的斐波那契數為:1 2 8 34, 他們的最小公倍數為136。

input

第1行:1個數n,表示數字的數量(2 <= n <= 50000)。

第2 至 n + 1行:每行1個數,對應ai。(1 <= ai <= 1000000)。

output

輸出lcm(f(a1), f(a2) ...... f(an)) mod 1000000007的結果。
input示例

413

69

output示例

136

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

神奇數論~

題解見知乎:

#include#include#includeusing namespace std;

#define ll long long

const int mod=1000000007;

int n,x,now,f[1000001],g[1000001],maxx,ans;

bool b[1000001];

int read()

while(ch>='0' && ch<='9')

return x*f;

}int mi(int u,int v)

int main()

for(int i=1;i<=n;i++)

for(int j=i;j<=n;j+=i)

if(b[j])

printf("%d\n",ans);

return 0;

}

51 nod 1350 斐波那契表示

每乙個正整數都可以表示為若干個斐波那契數的和,乙個整數可能存在多種不同的表示方法,例如 14 13 1 8 5 1,其中13 1是最短的表示 只用了2個斐波那契數 定義f n n的最短表示中的數字個數,f 14 2,f 100 3 100 3 8 89 f 16 2 16 8 8 13 3 定義g ...

51nod 1350 斐波那契表示 (數學)

每乙個正整數都可以表示為若干個斐波那契數的和,乙個整數可能存在多種不同的表示方法,例如 14 13 1 8 5 1,其中13 1是最短的表示 只用了2個斐波那契數 定義f n n的最短表示中的數字個數,f 14 2,f 100 3 100 3 8 89 f 16 2 16 8 8 13 3 定義g ...

51nod 1242 超大斐波那契(矩陣快速冪)

51nod 1242 斐波那契數列的定義如下 f 0 0 f 1 1 f n f n 1 f n 2 n 2 1,1,2,3,5,8,13,21,34,55,89,144,233,377,給出n,求f n 由於結果很大,輸出f n 1000000009的結果即可。input 輸入1個數n 1 n 1...