Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- bool *found;
- void check(int i){
- if(i>=0 && i<1000)
- if(!found[i])
- found[i]=true;
- }
- int abs(int i){
- if(i<0)
- return -i;
- return i;
- }
- void test(vector<int> list){
- if(list.size()==1)
- return;
- for(int i=0;i<list.size();i++){
- for(int j=i+1;j<list.size();j++){
- vector<int> temp=list;
- temp.erase(temp.begin()+j);
- temp[i]=list[i]+list[j];
- check(temp[i]);
- test(temp);
- temp[i]=list[i]*list[j];
- check(temp[i]);
- test(temp);
- temp[i]=abs(list[i]-list[j]);
- check(temp[i]);
- test(temp);
- if(list[j]!=0)
- if(!(list[i]%list[j])){
- temp[i]=list[i]/list[j];
- check(temp[i]);
- test(temp);
- }
- if(list[i]!=0)
- if(!(list[j]%list[i])){
- temp[i]=list[j]/list[i];
- check(temp[i]);
- test(temp);
- }
- }
- }
- }
- int main()
- {
- int N;
- vector<int> list;
- found=new bool[1000]();
- cin >> N;
- list.resize(N);
- for(int i=0;i<N;i++){
- cin>>list[i];
- found[list[i]]=true;
- }
- test(list);
- int foundn=0;
- for(int i=0;i<1000;i++){
- if(found[i])
- foundn++;
- }
- cout << foundn << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement