4 条题解
-
0
60pts
#include <bits/stdc++.h> using namespace std; #define int long long #define ull unsigned long long const int N=1e7+5; ull f[N]; signed main() { int m=3; f[1]=1ull*m; f[2]=1ull*m*(m-1); f[3]=1ull*m*(m-1)*(m-2); for(int i=4;i<N;i++) { f[i]=1ull*(m-1)*f[i-2]+1ull*(m-2)*f[i-1]; } int n; while(cin>>n) { cout<<f[n]<<'\n'; } return 0; }
信息
- ID
- 248
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 17
- 已通过
- 10
- 上传者