标签:一起 mes 解决 efi stdout [1] ref i++ return
2
4
1
4
dfs 打表前 10 项即可发现规律
a[i]=a[i-1]+a[i-3]+1
1 #include<stdio.h> 2 int num = 0; 3 int sum = 0; 4 void dfs(int n,int a){ 5 if(sum == n) 6 { 7 num ++; 8 return ; 9 } 10 dfs(n,a++); 11 12 } 13 int main() 14 { 15 int n; 16 long long a[1000]; 17 a[1]=1; 18 a[2]=1; 19 a[3]=2; 20 a[4]=4; 21 for(int i=5;i<=100;i++) 22 a[i]=a[i-1]+a[i-3]+1; 23 while(scanf("%d",&n)!=EOF) 24 { 25 // num = 0; 26 // dfs(n,1); 27 printf("%lld\n",a[n]); 28 } 29 }
打表
1 #include <bits/stdc++.h> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cstdio> 7 #include<string> 8 #include<vector> 9 #include<bitset> 10 #include<queue> 11 #include<deque> 12 #include<stack> 13 #include<cmath> 14 #include<list> 15 #include<map> 16 #include<set> 17 //#define DEBUG 18 #define RI register int 19 using namespace std; 20 typedef long long ll; 21 //typedef __int128 lll; 22 const int N=1000; 23 const int MOD=1e9+7; 24 const double PI = acos(-1.0); 25 const double EXP = 1E-8; 26 const int INF = 0x3f3f3f3f; 27 int t,n,m,k,q; 28 int ans=0; 29 int vis[110]; 30 void dfs(int x,int c){ 31 if(c>=n){ 32 ans++; 33 return; 34 } 35 int l=max(1,x-2); 36 int r=min(n,x+2); 37 for(int i=l;i<=r;i++){ 38 if(!vis[i]){ 39 vis[i]=1; 40 dfs(i,c+1); 41 vis[i]=0; 42 } 43 } 44 } 45 int main() 46 { 47 #ifdef DEBUG 48 freopen("input.in", "r", stdin); 49 //freopen("output.out", "w", stdout); 50 #endif 51 ll a[N]; 52 a[1]=1; 53 a[2]=1; 54 a[3]=2; 55 a[4]=4; 56 for(int i=5;i<=100;i++) 57 a[i]=a[i-1]+a[i-3]+1; 58 while(~scanf("%d",&n)){ 59 //ans=0; 60 //memset(vis,0,sizeof(vis)); 61 //vis[1]=1; 62 //dfs(1,1); 63 cout << a[n] << endl; 64 } 65 //cout << "Hello world!" << endl; 66 return 0; 67 }
标签:一起 mes 解决 efi stdout [1] ref i++ return
原文地址:https://www.cnblogs.com/DWVictor/p/10202517.html