标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 45288 Accepted Submission(s):
23092
import java.util.*;
class Main{
public static void main(String args[])
{Scanner cin=new Scanner(System.in);
int n=cin.nextInt();
while(n-->0)
{int m=cin.nextInt();
int [] a=new int [41];
a[0]=0;
a[1]=1;
a[2]=1;
if(m<=2)
System.out.println(a[m]);
else
{for(int j=3;j<=m;j++)
{a[j]=a[j-1]+a[j-2];}
System.out.println(a[m]);
}
}
}
}
这个题目是有规律的,仔细的推敲就会发现是菲薄拉切数列;
标签:
原文地址:http://www.cnblogs.com/1314wamm/p/5313124.html