Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int n;
- long long dp[115];
- int niza[115];
- long long fc(int i){
- if(i==n){
- return 1;
- }
- if(dp[i]!=-1){
- return dp[i];
- }
- long long result=0;
- int zbir=0;
- for(int j=i; j<n; j++){
- zbir+=niza[j];
- if(zbir==1){
- result+=fc(j+1);
- }
- }
- return dp[i] = result;
- }
- int main()
- {
- cin>>n;
- for(int i=0; i<n; i++){
- cin>>niza[i];
- }
- for(int i=0; i<n; i++){
- dp[i]=-1;
- }
- cout<<fc(0) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement