http://projecteuler.net/index.php?section=problems&id=25
以前作ったlongintクラスを使ってフィボナッチ数列を出すクラスを作る。
#include <iostream> #include "itertools.h" #include "longint.h" using namespace std; using namespace itertools; template<typename T> class fib { T a; T b; public: fib() { a = 0; b = 1; } T next() { T tmp = b; b += a; a = tmp; return a; } bool exists_next() { return true; } }; int main() { const int N = 1000; cout << fst(head(filter( [N] (tuple<int,longint> x) { return snd(x).length() == N; }, zip(itertools::count<>(1), fib<longint>())))) << endl; }