#include <iostream>
#include <numeric>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/iterator/transform_iterator.hpp>
int odd(int i)
{
return 2 * i + 1;
}
int square(int i)
{
return i * i;
}
typedef boost::counting_iterator <int> counter;
typedef boost::transform_iterator <int (*)(int), counter> transformer;
transformer odds(int n)
{
return transformer(counter(n), odd);
}
transformer squares(int n)
{
return transformer(counter(n), square);
}
int main()
{
using namespace std;
cout << "Enter vector length: ";
int n; cin >> n;
cout << inner_product( odds(0), odds(n), squares(0), 0 ) << endl;
}