Uva 177 Paper Folder 题解

本题是著名的折纸痕问题。。本是练习递归,但是我觉得模拟的成分更大。暂把它归为模拟题。

Url:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=113

XXX 说,模拟题是最简单的,我觉得模拟题其实是最难做的。


#include 
#include 
#include 
#include 
using namespace std;

#define Max 15

int turn[1<>1,0);
    getTurn(x+1,r,(r+x+1)>>1,1);
}
void getPos(int &x,int &y,int &w,int &h,int n)
{
    int dir = 0;
    int xx = 0,yy = 0;
    int pos_x = 0,pos_y = 0;
    int nec_x = 0,nec_y = 0;
    for(int i=0; i=0)
        {
            pos_x = max(pos_x,xx);
        }
        else
        {
            nec_x = min(nec_x,xx);
        }
        if(yy>=0)
        {
            pos_y = max(pos_y,yy);
        }
        else
        {
            nec_y = min(nec_y,yy);
        }
    }
    w = pos_y - nec_y + 1;
    h = pos_x - nec_x + 1;
    x = -nec_x;
    y = -nec_y;
    //printf("w = %d,h = %d,x = %d,y = %d\n",w,h,x,y);
}
void getFill(int k,int x,int y,int n)
{
    int xx = x,yy = y;
    int dir = 0;
    map[k][xx][yy] = '_';
    width[k][xx]=max(width[k][xx],yy);
    for(int i=0; i>1,0);
    getPos(x[k],y[k],w[k],h[k],n);
    getFill(k,x[k],y[k],n);
    getPrint(k);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
    int k;
    memset(map,0,sizeof(map));
    while(true)
    {
        scanf("%d",&k);
        if(k == 0)
        {
            break;
        }
        solve(k);
    }
    return 0;
}


你可能感兴趣的:(Algorithm_模拟)