CINTA第二次选做作业2

第三章第九题

题目: 定义 Fibonacci 数列如下: F ( 0 ) = 0 , F ( 1 ) = 1 F(0) = 0,F(1) = 1 F(0)=0F(1)=1,且对于 n ≥ 2 , F ( n ) = F ( n − 1 ) + F ( n − 2 ) n ≥ 2,F(n) = F(n − 1) + F(n−2) n2F(n)=F(n1)+F(n2)。所以,该数列是:0, 1, 1, 2, 3, 5, 8, 13, 21, . . . 。如何能快速地求出 F ( n ) F(n) F(n)呢?
[ 1 1 1 0 ] n = [ F ( n + 1 ) F ( n ) F ( n ) F ( n − 1 ) ] \begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix}^n=\begin{bmatrix} F(n+1) & F(n) \\ F(n) & F(n-1) \end{bmatrix} [1110]n=[F(n+1)F(n)F(n)F(n1)]
虽然,看上去该算法需要一次矩阵的指数运算,但是借助快速指数运算的方法,这 里可以产生一个快速求解 F ( n ) F(n) F(n) 的算法。请给出算法,并编程实现,C 语言或者 Python 都可以。
算法: 首先由公式可得: [ 1 1 1 0 ] n = [ 1 1 1 0 ] n − 1 ∗ [ 1 1 1 0 ] = [ F ( n ) F ( n − 1 ) F ( n − 1 ) F ( n − 2 ) ] ∗ [ 1 1 1 0 ] \begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix}^n=\begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix}^{n-1}*\begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix}=\begin{bmatrix} F(n) & F(n-1) \\ F(n-1) & F(n-2) \end{bmatrix}*\begin{bmatrix} 1 & 1 \\ 1 & 0 \end{bmatrix} [1110]n=[1110]n1[1110]=[F(n)F(n1)F(n1)F(n2)][1110]
= [ F ( n ) + F ( n − 1 ) F ( n ) F ( n − 1 ) + F ( n − 2 ) F ( n − 1 ) ] =\begin{bmatrix} {F(n)+F(n-1)} & F(n) \\ {F(n-1)+F(n-2)} & F(n-1) \end{bmatrix} =[F(n)+F(n1)F(n1)+F(n2)F(n)F(n1)]
由此可得,矩阵每进行一次乘法,结果的第一列的各行数据就是原来两列的两行数据之和,第二列就是原来的第一列,因此仅需进行加法和赋值即可。
答案: C++代码如下

int F1(int n)
{
	int f1 = 1, f2 = 1, f3 = 1, f4 = 0;
	n -= 1;//矩阵的n次方会进行n-1次相乘
	while (n--)
	{
		int tempf1 = f1, tempf3 = f3;//第一列
		f1 = f1 + f2;
		f3 = f3 + f4;
		f2 = tempf1;
		f4 = tempf3;
	}
	return f2;
}

第四章第十四题

题目: 给定任意正整数 n , n n,n nn 的所有因子分别记为 d 0 , d 1 , ⋯   , d r , d_0, d_1, \cdots , d_r, d0,d1,,dr其中包括 1 1 1 n n n。记函数:
F ( n ) = ϕ ( d 0 ) + ϕ ( d 1 ) + ⋅ ⋅ ⋅ + ϕ ( d r ) F(n)={\phi(d_0)+\phi(d_1)+· · ·+\phi(d_r)} F(n)=ϕ(d0)+ϕ(d1)+⋅⋅⋅+ϕ(dr)
现在需要证明 F ( n ) = n F(n) = n F(n)=n。为完成这个任务,请依次完成以下小任务:
( a ) (a) (a). 证明,对任意素数 p , F ( p ) = p p,F(p) = p pF(p)=p
( b ) (b) (b). 证明,对任意素数 p , F ( p 2 ) = p 2 p,F(p^2) = p^2 pF(p2)=p2
( c ) (c) (c). 证明,对任意素数 p , F ( p k ) = p k p,F(p^k) = p^k pF(pk)=pk k k k 是任意正整数。
( d ) (d) (d). 证明,对任意素数 p 和 q p 和 q pq F ( p q ) = p q F(pq) = pq F(pq)=pq
( e ) (e) (e). 证明函数 F 是积性函数,即对任意的正整数 m 和 n m 和 n mn,如果 g c d ( m , n ) = 1 gcd(m, n) = 1 gcd(m,n)=1,则 F ( m n ) = F ( m ) F ( n ) F(mn) = F(m)F(n) F(mn)=F(m)F(n)。[提示:既然 m 与 n 互素,则它们之间就不存在大于一 的公因子,那么它们的因子相乘之后作用于欧拉函数会满足什么特性?]
( f ) (f) (f). 最后,完成证明 F ( n ) = n F(n) = n F(n)=n的任务。[提示:任意整数 n 都是素数的乘积,即 n = p 0 k 0 p 1 k 1 ⋅ ⋅ ⋅ p t k t n =p_0^{k_0} p_1^{k_1} · · · p_t^{k_t} n=p0k0p1k1⋅⋅⋅ptkt 。]
解:
( a ) . (a). (a).对于任意素数 p p p,有两个因子 1 和 p 1和p 1p,所以有 F ( p ) = ϕ ( 1 ) + ϕ ( p ) F(p)=\phi(1)+\phi(p) F(p)=ϕ(1)+ϕ(p),根据欧拉 P h i Phi Phi函数性质有 ϕ ( p ) = p − 1 \phi(p)=p-1 ϕ(p)=p1,所以 F ( p ) = ϕ ( 1 ) + ϕ ( p ) = 1 + p − 1 = p F(p)=\phi(1)+\phi(p)=1+p-1=p F(p)=ϕ(1)+ϕ(p)=1+p1=p,题目得证。
( b ) . (b). (b).对于任意素数 p p p p 2 p^2 p2有三个因子 1 , p , p 2 1,p,p^2 1,p,p2
∴ F ( p 2 ) = ϕ ( 1 ) + ϕ ( p ) + ϕ ( p 2 ) \therefore F(p^2)=\phi(1)+\phi(p)+\phi(p^2) F(p2)=ϕ(1)+ϕ(p)+ϕ(p2)
根据欧拉 P h i Phi Phi函数性质有 ϕ ( p k ) = p k − p k − 1 \phi(p^k)=p^k-p^{k-1} ϕ(pk)=pkpk1
∴ F ( p 2 ) = ϕ ( 1 ) + ϕ ( p ) + ϕ ( p 2 ) = 1 + p − 1 + p 2 − p = p 2 \therefore F(p^2)=\phi(1)+\phi(p)+\phi(p^2)=1+p-1+p^2-p=p^2 F(p2)=ϕ(1)+ϕ(p)+ϕ(p2)=1+p1+p2p=p2即题目得证。
( c ) . (c). (c).对于任意素数 p , p k p,p^k p,pk有因子 1 , p , p 2 ⋯ p k 1,p,p^{2}\cdots p^k 1,p,p2pk
∴ F ( p k ) = ϕ ( 1 ) + ϕ ( p ) + ⋯ + ϕ ( p k ) \therefore F(p^k)=\phi(1)+\phi(p)+\cdots+\phi(p^k) F(pk)=ϕ(1)+ϕ(p)++ϕ(pk)
= 1 + p − 1 + p 2 − p + ⋯ + p k − 1 − P k − 2 + p k − p k − 1 =1+p-1+p^2-p+\cdots+p^{k-1}-P^{k-2}+p^k-p^k-1 =1+p1+p2p++pk1Pk2+pkpk1
= P k =P^k =Pk ∴ \therefore 题目得证。
( d ) . (d). (d).对于任意素数 p 和 q p和q pq p q pq pq有因子 1 , p , q , p q 1,p,q,pq 1,p,q,pq
∴ F ( p q ) = ϕ ( 1 ) + ϕ ( p ) + ϕ ( q ) + ϕ ( p q ) \therefore F(pq)=\phi(1)+\phi(p)+\phi(q)+\phi(pq) F(pq)=ϕ(1)+ϕ(p)+ϕ(q)+ϕ(pq)
= 1 + p − 1 + q − 1 + ( p − 1 ) ( q − 1 ) =1+p-1+q-1+(p-1)(q-1) =1+p1+q1+(p1)(q1)
= p q ∴ =pq\therefore =pq题目得证
( e ) . (e). (e).对任意的正整数 m 和 n m 和 n mn,如果 g c d ( m , n ) = 1 gcd(m, n) = 1 gcd(m,n)=1,即 m 与 n m与n mn互素,则 m m m的因子与 n n n的因子也都是互素的,设 m m m的因子为 d m 1 , d m 2 ⋯ d m x , d_{m1},d_{m{2}}\cdots d_{mx}, dm1dm2dmx包括 1 和 m 1和m 1m,共有 x x x个, n n n的因子设为 d n 1 , d n 2 ⋯ d n y d_{n1},d_{n{2}}\cdots d_{ny} dn1dn2dny,包括 1 和 n 1和n 1n,共有 y y y个,
m n mn mn的因子有 d m 1 d n 1 , d m 1 d n 2 ⋯ d m 1 d n y d_{m1}d_{n1},d_{m1}d_{n{2}}\cdots d_{m1}d_{ny} dm1dn1dm1dn2dm1dny , d m 2 d n 1 , d m 2 d n 2 ⋯ d m 2 d n y ⋯ ,d_{m{2}}d_{n1},d_{m{2}}d_{n{2}}\cdots d_{m{2}}d_{ny}\cdots dm2dn1dm2dn2dm2dny ⋯ , d m x d n 1 , d m x d n 2 ⋯ d m x d n y \cdots ,d_{mx}d_{n1},d_{mx}d_{n{2}}\cdots d_{mx}d_{ny} dmxdn1dmxdn2dmxdny x y xy xy个因子。
∴ F ( m n ) = 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F(m)F(n),即题目得证。
( f ) . (f). (f).任意整数 n 都是素数的乘积,即 n = p 0 k 0 p 1 k 1 ⋅ ⋅ ⋅ p t k t n =p_0^{k_0} p_1^{k_1} · · · p_t^{k_t} n=p0k0p1k1⋅⋅⋅ptkt 。可得 F ( n ) = F ( p 0 k 0 p 1 k 1 ⋅ ⋅ ⋅ p t k t ) F(n)=F(p_0^{k_0} p_1^{k_1} · · · p_t^{k_t}) F(n)=F(p0k0p1k1⋅⋅⋅ptkt),又由 ( e ) (e) (e)中的结论可得
F ( n ) = F ( p 0 k 0 p 1 k 1 ⋯ p t k t ) F(n)=F(p_0^{k_0} p_1^{k_{1}} \cdots p_t^{k_t}) F(n)=F(p0k0p1k1ptkt)
= F ( p 0 k 0 ) F ( p 1 k 1 ) ⋯ F ( p t k t ) =F(p_0^{k_0})F(p_1^{k_{1}})\cdots F(p_t^{k_t}) =F(p0k0)F(p1k1)F(ptkt)
又由 ( c ) (c) (c)的结论 F ( p k ) = p k F(p^k)=p^k F(pk)=pk可得
F ( n ) = F ( p 0 k 0 ) F ( p 1 k 1 ) ⋯ F ( p t k t ) = p 0 k 0 p 1 k 1 ⋯ p t k t = n F(n)=F(p_0^{k_0})F(p_1^{k_{1}})\cdots F(p_t^{k_t})=p_0^{k_0} p_1^{k_{1}} \cdots p_t^{k_t}=n F(n)=F(p0k0)F(p1k1)F(ptkt)=p0k0p1k1ptkt=n即题目得证。

好的,这里是50种不同国家的语言表达“我爱你”: 1. English - I love you 2. Spanish - Te quiero 3. French - Je t'aime 4. German - Ich liebe Dich 5. Italian - Ti amo 6. Portuguese - Eu te amo 7. Russian - Ya lyublyu tebya 8. Chinese (Mandarin) - Wo ai ni 9. Japanese - Aishiteru 10. Korean - Sarang hae 11. Arabic - Ana behibak (to a male) / Ana behibek (to a female) 12. Dutch - Ik hou van je 13. Danish - Jeg elsker dig 14. Swedish - Jag älskar dig 15. Norwegian - Jeg elsker deg 16. Finnish - Minä rakastan sinua 17. Polish - Kocham Cię 18. Czech - Miluji Tě 19. Hungarian - Szeretlek 20. Bulgarian - Obicham te 21. Greek - S'ayapo 22. Turkish - Seni seviyorum 23. Romanian - Te iubesc 24. Croatian - Volim te 25. Serbian - Volim te 26. Slovenian - Ljubim te 27. Slovak - Milujem Ťa 28. Estonian - Ma armastan sind 29. Latvian - Es tevi mīlu 30. Lithuanian - Aš tave myliu 31. Icelandic - Ég elska þig 32. Albanian - Te dua 33. Thai - Phom rak khun (to a male) / Chan rak khun (to a female) 34. Vietnamese - Anh ye^u em (to a female) / Em ye^u anh (to a male) 35. Indonesian - Saya cinta padamu 36. Filipino - Mahal kita 37. Hindi - Main tumse pyar karta hoon 38. Bengali - Ami tomake bhalobashi 39. Urdu - Main tumse muhabbat karta hoon 40. Marathi - Me tujhe pyaar kartaa hoo 41. Punjabi - Main tere pyar da haan 42. Telugu - Nenu ninnu premisthunnanu 43. Tamil - Naan unnai kaadhalikken 44. Malayalam - Njan ninnodenikkoo 45. Kannada - Naanu ninna preetisuttene 46. Gujrati - Hu tane pyar karoo chu 47. Nepali - Ma timilai maya garchu 48. Sinhala - Mama oyata arderyi 49. Burmese - Chit pa de 50. Mongolian - Bi chamd hairtai
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值