Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
128797 | 11 | 找规律1 | C++ | 通过 | 100 | 0 MS | 272 KB | 360 | 2024-01-26 09:49:57 |
#include<bits/stdc++.h> #define int long long using namespace std; int dp[205]; signed main(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int n; cin>>n; dp[1] = 2; cout<<"2 "; for (int i = 2;i <= n;i++){ if (i & 1){ dp[i] = dp[i - 1] + 3; } else{ dp[i] = dp[i - 1] - 1; } cout<<dp[i]<<' '; } return 0; }