题意:
有n个点围成一圈,这n个点的匹配就是没有公共点的边集(这些边只能连接一圈中相邻的两点),求所有匹配的个数。
额,我不会分析。。=_=||
算了几个数,找找规律发现它满足斐波那契数列的递推关系,f(n) = f(n-1) + f(n-2)
自从会用了Java的BigInteger,就懒得写C的高精度了。
1 import java.io.*; 2 import java.util.*; 3 import java.math.*; 4 5 public class Main 6 { 7 static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); 8 9 public static void main(String args[]) throws IOException 10 { 11 BigInteger [] a = new BigInteger[10002]; 12 a[3] = new BigInteger("4"); 13 a[4] = new BigInteger("7"); 14 for(int i = 5; i <= 10000; ++i) a[i] = a[i-1].add(a[i-2]); 15 Scanner cin=new Scanner(System.in); 16 while(cin.hasNext()) 17 { 18 int n = cin.nextInt(); 19 System.out.println(a[n]); 20 } 21 } 22 }