#C++11, 360 bytes
C++11, 360 bytes
Hi I just like this question. I know c++ is a very hard language to win this competition. But I'll thrown a dime any way.
#include<vector>
#include<numeric>
#include<iostream>
using namespace std;typedef vector<int>v;void p(v& i) {for(auto&v:i)cout<<v<<" ";cout<<endl;}v b(int s,int n){v r(n<s?n:s,1);r.reserve(n);for(auto i=r.begin();r.size()<n;i++){r.push_back(accumulate(i,i+s,0));}return r;}int main(int c, char** a){if(c<3)return 1;v s=b(atoi(a[1]),atoi(a[2]));p(s);return 0;}
I'll leave this as the readable explanation of the code above.
#include <vector>
#include <numeric>
#include <iostream>
using namespace std;
typedef vector<int> vi;
void p(const vi& in) {
for (auto& v : in )
cout << v << " ";
cout << endl;
}
vi bonacci(int se, int n) {
vi s(n < se? n : se, 1);
s.reserve(n);
for (auto it = s.begin(); s.size() < n; it++){
s.push_back(accumulate(it, it + se, 0));
}
return s;
}
int main (int c, char** v) {
if (c < 3) return 1;
vi s = bonacci(atoi(v[1]), atoi(v[2]));
p(s);
return 0;
}