标签:des style blog class code java
Time Limit: 1000MS | Memory Limit: 65535KB |
Submissions: 117 | Accepted: 69 |
3 4
5 11
#include <iostream> #include <stdio.h> using namespace std; int n,num; int b[3]={1,2,2}; void dfs(int index) { int i; if(index>n) { return ; } if(index==n) { num++; } for(i=0;i<3;i++) { dfs(index+b[i]); } } int main() { while(scanf("%d",&n)!=EOF) { num = 0; dfs(0); printf("%d\n",num); } return 0; }
规律
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 |
# include<stdio.h> int
f( int
n) { if (n==1) return
1; if (n==2) return
3; return
2*f(n-2)+f(n-1); } int
main() { int
n; while ( scanf ( "%d" ,&n)!=EOF) { printf ( "%d\n" ,f(n)); } return
0; } |
标签:des style blog class code java
原文地址:http://www.cnblogs.com/locojyw/p/3704854.html