費氏數列節點數遞迴公式:
f[0]=f[1]=1,
f[n]=f[n-1]+f[n-2]+1, n>=2
求f[n] n=2,3,...,50
herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
先說明一下這是後知後覺的解答,所謂後知就是股票價格已知存在陣列(清單),當然就要用迴圈練習,雙迴圈暴力解需時O(n**2),當然不用,採python單一迴圈解答「最佳股票的買賣時機#LeetCode 121 Best Time to Buy and Sell Stock」,解...
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
你會用C的算子sizeof?
-
Python CPP heap priority queue速解L eetcode 2530. Maximal Score After Applying K Operations heap/priority queue是重要的資料結構,無論是C++的std::priority_q...
-
C++ DP動態規劃解Leetcode 937 Maximum Number of Points with Cost 有些標示medium要比標示hard的問題還要難,Leetcode 1937. Maximum Number of Points with Cost,DP動態規...
40 則留言:
public class AA {
static long gcd(long x,long y)
{
long r=x%y;
if(r==0)
return y;
else
return gcd(y,r);
}
static public void main(String gcd[])
{
long x=10^10+1,y=10^11+2;
System.out.print("gcd:"+gcd(x,y));
}
}
public class fas {
public static void main (String argv[])
{
long f[]= new long [51];
f[0]=f[1]=1;
for (int n=2; n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
public class b9833103 {
public static void main (String argv[])
{
long g[]=new long [51];
g[0]=g[1]=1;
for (int i=2; i<51;i++)
{
g[i]=g[i-1]+g[i-2]+1;
System.out.println(i+"---->"+g[i]);
}
}
}
47---->9615053951
48---->15557484097
49---->25172538049
50---->40730022147
Process completed.
public class ex3
{
static public void main (String agv[])
{
long f[]=new long[51];
f[0]=f[1]=1;
for(int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+" "+f[n]);
}
}
}
public class b9833103 {
public static void main (String argv[])
{
long g[]=new long [51];
g[0]=g[1]=1;
for (int i=2; i<51;i++)
{
g[i]=g[i-1]+g[i-2]+1;
System.out.println(i+"---->"+g[i]);
}
}
}
47---->9615053951
48---->15557484097
49---->25172538049
50---->40730022147
Process completed.
public class fas {
public static void main(String argv[])
{
long g[]=new long [51];
g[0]=g[1]=1;
for (int i=2 ; i<51 ; i++)
{
g[i]=g[i-1]+g[i-2]+1;
System.out.println(i+"---->"+g[i]);
}
}
}
public class fs {
public static void main(String[] erg) {
long fs[]=new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}}
}
public class b9833065
{
static public void main (String agv[])
{
long f[]=new long[51];
f[0]=f[1]=1;
for(int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+" "+f[n]);
}
}
}
public class B {
public static void main(String argv[] )
{
long f[]=new long[51];
f[0]=f[1]=1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
--------------------Configuration: <Default>--------------------
2-->3
3-->5
4-->9
5-->15
6-->25
7-->41
8-->67
9-->109
10-->177
11-->287
12-->465
13-->753
14-->1219
15-->1973
16-->3193
17-->5167
18-->8361
19-->13529
20-->21891
21-->35421
22-->57313
23-->92735
24-->150049
25-->242785
26-->392835
27-->635621
28-->1028457
29-->1664079
30-->2692537
31-->4356617
32-->7049155
33-->11405773
34-->18454929
35-->29860703
36-->48315633
37-->78176337
38-->126491971
39-->204668309
40-->331160281
41-->535828591
42-->866988873
43-->1402817465
44-->2269806339
45-->3672623805
46-->5942430145
47-->9615053951
48-->15557484097
49-->25172538049
50-->40730022147
Process completed.
/**
* @(#)tasty.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class tasty
{
static public void main (String agv[])
{
long f[]=new long[51];
f[0]=f[1]=1;
for(int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+" "+f[n]);
}
}
}
/**
* @(#)aaaaaa.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class aaaaaa {
public static void main (String argv[] )
{
long f[]=new long[51];
f[0]=f[1]=1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
--------------------Configuration: <Default>--------------------
2-->3
3-->5
4-->9
5-->15
6-->25
7-->41
8-->67
9-->109
10-->177
11-->287
12-->465
13-->753
14-->1219
15-->1973
16-->3193
17-->5167
18-->8361
19-->13529
20-->21891
21-->35421
22-->57313
23-->92735
24-->150049
25-->242785
26-->392835
27-->635621
28-->1028457
29-->1664079
30-->2692537
31-->4356617
32-->7049155
33-->11405773
34-->18454929
35-->29860703
36-->48315633
37-->78176337
38-->126491971
39-->204668309
40-->331160281
41-->535828591
42-->866988873
43-->1402817465
44-->2269806339
45-->3672623805
46-->5942430145
47-->9615053951
48-->15557484097
49-->25172538049
50-->40730022147
Process completed.
/**
* @(#)FI.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class FI {
static public void main(String FI[])
{
long f[]=new long[51];
f[0]=f[1]=1;
for(int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"->"+f[n]);
}
}
}
class f
{
public static void main(String arg[])
{
float a=1,b=1,c=0;
int i=0;
for(i=1;i<=50;i++)
{
c=a+b;
b=a;
a=c;
}
System.out.println(c);
}
}
/**
* @(#)B.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class B {
public static void main(String argv[] )
{
long f[]=new long[51];
f[0]=f[1]=1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
/**
* @(#)B.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class B {
public static void main(String argv[] )
{
long f[]=new long[51];
f[0]=f[1]=1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
/**
* @(#)B.java
*
*
* @author
* @version 1.00 2010/11/1
*/
public class B {
public static void main(String argv[] )
{
long f[]=new long[51];
f[0]=f[1]=1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+"-->"+f[n]);
}
}
}
public class B9833073
{
static public void main (String agv[])
{
long f[]=new long[51];
f[0]=f[1]=1;
for(int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2]+1;
System.out.println(n+" "+f[n]);
}
}
}
public class B9833071 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class B9833066 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
<
public class two {
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class two {
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class f {
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class two {
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class B9733153
{
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class B9733153
{
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class B9833084
{
public static void main(String[] erg)
{
long fs[]= new long[51];
fs[0]=fs[1]=1;
System.out.println("0:"+fs[0]);
System.out.println("1:"+fs[1]);
for (int i=2;i<51;i++){
fs[i]=fs[i-1]+fs[i-2]+1;
System.out.println(i+":"+fs[i]);
}
}
}
public class EX456 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class java1101.02 {
public static void main(String[] erg){
long X[]= new long[51];
X[0]=X[1]=1;
System.out.println("0:"+X[0]);
System.out.println("1:"+X[1]);
for (int i=2;i<51;i++){
X[i]=X[i-1]+X[i-2]+1;
System.out.println(i+":"+X[i]);
}
}
}
public class abc {
public static void main (String argv[])
{
long f[]= new long [51];
f[0]=f[1]=1;
for (int a=2; a<51;n++)
{
f[a]=f[a-1]+f[a-2]+1;
System.out.println(a+"--->"+f[a]);
}
}
}
public class a1 {
public static void main(String []args)
{
` double a=1,b=1,c=0;
int i=0;
for(i=1;i<=50;i++)
{
c=a+b;
b=a;
a=c;
}
System.out.println(c);
}
}
public class B9833061 {
public static void main(String arg[])
{ long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class B9833088 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
public class EX07 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class EX12 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class EX07 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class b9833075 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class b9833094 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class B9833115 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class B9833116 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
public class B9833118 {
public static void main(String arg[])
{
long f[] = new long [51];
f[0]= f[1]= 1;
for (int n=2;n<51;n++)
{
f[n]=f[n-1]+f[n-2];
System.out.println(n+"->"+f[n]);
}
}
}
張貼留言