dp复习与dp优化(简单优化)
输出样例2
21
输入样例1
2
输出样例1
3
输入样例2
4#includeusing namespace std; long long n,a=1,b,c,d; const int mod=1e9+7; int main(){ cin>>n; for(int i=1;i<=n;i++) { long long aa,bb,cc,dd; aa=b+c+d; bb=a+c+d; cc=a+b+d; dd=a+b+c; a=aa%mod; b=bb%mod; c=cc%mod; d=dd%mod; } cout< 第2题程序题(宝物筛选)
(做一做)
简单优化
第1题程序题(Tetrahedron)
题目描述
输入格式
The first line contains the only integer n ( 1<=n<=107 ) — the required length of the cyclic path.
输出格式
Print the only integer — the required number of ways modulo 1000000007 ( 109+7 ).
说明/提示
The required paths in the first sample are:
- D−A−D
- D−B−D
- D−C−D
题目描述
终于,破解了千年的难题。小 FF 找到了王室的宝物室,里面堆满了无数价值连城的宝物。
这下小 FF 可发财了,嘎嘎。但是这里的宝











