1 . 青蛙爬楼梯 ,经典 DP 问题,改变 就是不能连续跳
所以 dp[i] =dp[i-1]+dp[i-3];
神奇 的默认输入方式
#include<bits/stdc++.h> using namespace std; #define LOACL freopen("in","r",stdin);\freopen("out","w",stdout); #define FASTIO ios::sync_with_stdio(false); #define CLOCK cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";const int inf = 987654321; const int sz = (int)1e6 + 5; const int mod = (int)1e9 + 7; const int sqrtn = 300; //#define add(u,v,w) (e[++tot]=(edge){v,head[u],1},head[u]=tot;) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define DBG(x) cout<<(#x)<<"="<<x<<endl #define DBG2(x,y) cout<<(#x)<<"="<<x<<"\t"<<(#y)<<"="<<y<<endl #define DBG3(x,y,z) cout<<(#x)<<"="<<x<<"\t"<<(#y)<<"="<<y<<"\t"<<(#z)<<"="<<z<<endl#define FOR(i, a, b) for(int i=(a); i<(b); i++) #define REP(i, a, b) for(int i=(a); i<=(b); i++) #define DOWN(i, a, b) for(int i=(a); i>=(b); i--)#define all(x) x.begin(),x.end() #define low(x) (x)&(-x) #define pb push_back typedef long long ll; typedef double dl; int dp[55]; int jump(int num) {return dp[num]; } int main() {LOACLdp[0]=1;dp[1]=1;dp[2]=2;REP(i,3,54){dp[i]+=dp[i-1];dp[i]+= dp[i-3] ; }//REP(i,1,54) DBG2(i,dp[i]);string line;while(getline(cin, line)){stringstream ss(line);int num = 0;ss >> num;if(num == 0) break;cout << jump(num) << endl;}return 0; }
2. n 个人 做 n个座位 不做自己的 . 还有多余的一个人 做对了
数论问题 dp[i] =(i-1)*(dp[i-1]+dp[i-2])
#include<bits/stdc++.h> using namespace std; #define LOACL freopen("in","r",stdin);\freopen("out","w",stdout); #define FASTIO ios::sync_with_stdio(false); #define CLOCK cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";const int inf = 987654321; const int sz = (int)1e6 + 5; const int mod = (int)1e9 + 7; const int sqrtn = 300; //#define add(u,v,w) (e[++tot]=(edge){v,head[u],1},head[u]=tot;) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define DBG(x) cout<<(#x)<<"="<<x<<endl #define DBG2(x,y) cout<<(#x)<<"="<<x<<"\t"<<(#y)<<"="<<y<<endl #define DBG3(x,y,z) cout<<(#x)<<"="<<x<<"\t"<<(#y)<<"="<<y<<"\t"<<(#z)<<"="<<z<<endl#define FOR(i, a, b) for(int i=(a); i<(b); i++) #define REP(i, a, b) for(int i=(a); i<=(b); i++) #define DOWN(i, a, b) for(int i=(a); i>=(b); i--)#define all(x) x.begin(),x.end() #define low(x) (x)&(-x) #define pb push_back typedef long long ll; typedef double dl; int dp[70]; int ff(int n) {if(n<0) return 0;if(n==1) return 1 ;if(n==2) return 0;return n*dp[n-1];} int main() {LOACLdp[0]=dp[1]=0;dp[2]= 1;REP(i,3,66){dp[i]=(i-1)*(dp[i-1]+dp[i-2]);}// REP(i,2,66) DBG(dp[i]);int n;while(cin>>n)cout<<ff(n)<<endl;return 0; }
看来今年春招,我是都找不到实习的地方了,像进攻机器学习领域,好难累成狗也不一定有成果,但是 那又如何
嗓子发炎了好疼,没有地方吐槽 ,还好我心态好,
怕不是我 佛系人生真的越来越真实了.一个人哭,真爱无敌,想你O