1 /** 2 * Created by Administrator on 14-5-15. 3 */ 4 public class NewCow_DP { 5 public static void main(String[] args){ 6 int[] cows=new int[31]; 7 cows[1]=1; 8 cows[2]=1; 9 cows[3]=2; 10 for(int i=4;i<=30;i++){ 11 cows[i]=cows[i-1]+cows[i-3]; 12 } 13 for(int i=1;i<=30;i++) 14 System.out.println(i+"年后有牛:"+cows[i]); 15 } 16 }
时间: 2024-10-12 16:05:16