-
A - Por Costel and Azerah
- Gym - 100923A
-
#include <iostream> #include <stdio.h> #include <cmath> using namespace std; #define maxn 1000052 #define ll long long #define md 1000000007 ll t,n,x,dp[maxn][5]; int main() { freopen("azerah.in","r",stdin); freopen("azerah.out","w",stdout); scanf("%lld",&t); while(t--) { scanf("%lld",&n); dp[0][1]=0; dp[0][0]=1; for(ll i=1; i<=n; i++) { scanf("%lld",&x); if(x%2==0) { dp[i][0]=(2*dp[i-1][0])%md; dp[i][1]=2*dp[i-1][1]%md; //重组替换两种操作。 } else dp[i][1]=dp[i][0]=(dp[i-1][1]+dp[i-1][0])%md; } printf("%lld\n",dp[n][0]-1); } return 0; }
A - Por Costel and Azerah-dp求和
最新推荐文章于 2019-08-17 23:45:00 发布