4 条题解
-
0
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int>su(n+1); for (int i = 1; i <= n; i++)cin >> su[i]; int way[1001]; way[1] = 0; way[2] = 1; way[3] = 2; for (int i = 1; i <= n; i++) { for (int j = 4; j <= su[i]; j++) way[j] = way[j - 1] + way[j - 2]; cout << way[su[i]] << endl; }
return 0;
}
-
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); //次数为n int[] m=new int[n]; for (int i = 0; i < n; i++) { m[i]=sc.nextInt()-1; } int[][] dp=new int [n][45]; for (int i = 0; i < n; i++) { dp[i][0]=1; dp[i][1]=1; dp[i][2]=2; } for (int i = 0; i < n; i++) { //次数 for (int j = 2; j <= m[i]; j++) { // dp[i][j]=dp[i][j-1]+dp[i][j-2]; } } for (int i = 0; i < n; i++) { System.out.println(dp[i][m[i]]); } } }
- 1
信息
- ID
- 129
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 296
- 已通过
- 114
- 上传者