import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int []a=new int [100]; a[0]=0;a[1]=1;a[2]=2;a[3]=3;a[4]=4; while(true){ int n=sc.nextInt(); //输入n if(n==0) break; for(int i=5;i<=n;i++){ a[i]=a[i-1]+a[i-3]; } System.out.println(a[n]); } } }
找规律动态规划
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:695 |
A+B for Input-Output Practice (V) (C语言代码)浏览:451 |
字符串的输入输出处理 (C语言代码)浏览:671 |
奖学金 (C++代码)浏览:2008 |
ASCII帮了大忙浏览:749 |
妹子杀手的故事 (C语言代码)浏览:1234 |
求组合数 (C语言代码)浏览:1159 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)万恶的long long浏览:880 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:485 |
WU-陶陶摘苹果2 (C++代码)浏览:975 |