#include <iostream> #include <math.h> #include <vector> #include <algorithm> #include <queue> #include <typeinfo> #define c_plus_plus std #define QED return 0; } #define NOT_QED return -1 #define CNU return #define kiedy_kliknieto_zielona_flage int main(){ #define ll long long #define mp make_pair #define str string #define vec vector #define pb push_back #define foru(u, n) for(int u=0;u<n;u++) #define INT_MAX 2147483647 #define LL_MAX 9223372036854775807LL #define ir(a, b, x) ((a<=x)&&(x<=b)) #define f first #define s second #define ll long long #define vll vec<ll> #define p pair<ll, ll> #define pq priority_queue using namespace c_plus_plus; #define N 300000 #define P 1000000007 ll n; ll a[N]; ll ans[N+1]; kiedy_kliknieto_zielona_flage foru(i, N) ans[i]=0; cin >> n; for(int i=0;i<n;i++) cin >> a[i]; ans[n]=1; for(int i=n-1;i>=0;i--){ ll s = 0; for(int j=i;j<n;j++){ s+=a[j]; s=s%P; if(s%2==0){ ans[i]+=ans[j+1]; ans[i]=ans[i]%P; } } } cout << ans[0]; QED
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #include <iostream> #include <math.h> #include <vector> #include <algorithm> #include <queue> #include <typeinfo> #define c_plus_plus std #define QED return 0; } #define NOT_QED return -1 #define CNU return #define kiedy_kliknieto_zielona_flage int main(){ #define ll long long #define mp make_pair #define str string #define vec vector #define pb push_back #define foru(u, n) for(int u=0;u<n;u++) #define INT_MAX 2147483647 #define LL_MAX 9223372036854775807LL #define ir(a, b, x) ((a<=x)&&(x<=b)) #define f first #define s second #define ll long long #define vll vec<ll> #define p pair<ll, ll> #define pq priority_queue using namespace c_plus_plus; #define N 300000 #define P 1000000007 ll n; ll a[N]; ll ans[N+1]; kiedy_kliknieto_zielona_flage foru(i, N) ans[i]=0; cin >> n; for(int i=0;i<n;i++) cin >> a[i]; ans[n]=1; for(int i=n-1;i>=0;i--){ ll s = 0; for(int j=i;j<n;j++){ s+=a[j]; s=s%P; if(s%2==0){ ans[i]+=ans[j+1]; ans[i]=ans[i]%P; } } } cout << ans[0]; QED |