[ create a new paste ] login | about

Link: http://codepad.org/OBJKConC    [ raw code | output | fork ]

C++, pasted on May 18:
#include <iostream>
#include <iomanip>
#include <boost/progress.hpp>
#include <tfm.h>

static size_t const maxx = 1000;
static size_t const maxy = 1000;
static size_t const historysteps = maxx + maxy - 1;
static fp_int gridcount[maxx][maxy];
static fp_int * history[historysteps];
static size_t current = 0;

void draw(fp_int const & a)
{
    for (int x = a.used - 1; x >= 0; x--)
        std::cout << std::hex << std::setw(8) << std::setfill('0') << a.dp[x];

    std::cout << std::endl;
}

void addTile(size_t x, size_t y)
{
    if(!fp_iszero(&gridcount[x][y]))
    {
        for(size_t i = 0; i < current; ++i)
            fp_add(history[i], &gridcount[x][y], history[i]);
        
        return;
    }
    
    history[current++] = &gridcount[x][y];
        
    if(x < maxx - 1)
        addTile(x + 1, y);
    
    if(y < maxy - 1)
        addTile(x, y + 1);
    
    if(x == maxx - 1 && y == maxy - 1)
        for(size_t i = 0; i < historysteps; ++i)
            fp_add_d(history[i], 1, history[i]);

    --current;
}

int main()
{
    { boost::progress_timer _timer;
      addTile(0, 0); }

    std::cout << std::endl << "Result: "; draw(gridcount[0][0]);
    return 0;
}


Output:
1
2
3
Line 16: error: tfm.h: No such file or directory
Line 9: error: 'fp_int' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: