Created
February 4, 2014 13:58
-
-
Save taikoubou/8804018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
using namespace std; | |
void solve(int,int); | |
vector<int> d; | |
vector<int> point; | |
int n; | |
int ans=0; | |
int main(){ | |
cin >> n; | |
for(int i=0;i<n;i++){ | |
int temp; | |
cin >> temp; | |
d.push_back(temp); | |
} | |
solve(0,0); | |
cout << ans << endl; | |
} | |
void solve(int h,int p){ | |
if(h == n){ | |
return ; | |
} | |
else{ | |
ans++; | |
solve(h+1,p); | |
bool f = true; | |
for(int i=0;i<point.size();i++){ | |
if(point[i] == p+d[h+1])f = false; | |
} | |
if(f){ | |
point.push_back(p+d[h+1]); | |
solve(h+1,p+d[h+1]); | |
} | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment