Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
33642 | liusiyu | 上台阶 | C++ | Accepted | 0 MS | 248 KB | 259 | 2023-12-11 18:31:47 |
#include<bits/stdc++.h> using namespace std; int main() { int n; int a[35]={}; while(cin>>n){ if(n==0) break; a[1]=1; a[2]=2; a[3]=4; for(int i=4;i<=n;i++){ a[i]=a[i-1]+a[i-2]+a[i-3]; } cout<<a[n]<<endl; } return 0; }