锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久综合久久综合久久,亚洲AV伊人久久青青草原,久久99国产精品久久http://www.shnenglu.com/huicpc0860/category/14095.htmlEverything has its history.zh-cnFri, 04 Mar 2011 11:39:46 GMTFri, 04 Mar 2011 11:39:46 GMT60- uva 10181 15-Puzzle Problemhttp://www.shnenglu.com/huicpc0860/archive/2011/03/04/141094.htmlhuicpc0860huicpc0860Fri, 04 Mar 2011 02:00:00 GMThttp://www.shnenglu.com/huicpc0860/archive/2011/03/04/141094.htmlhttp://www.shnenglu.com/huicpc0860/comments/141094.htmlhttp://www.shnenglu.com/huicpc0860/archive/2011/03/04/141094.html#Feedback0http://www.shnenglu.com/huicpc0860/comments/commentRss/141094.htmlhttp://www.shnenglu.com/huicpc0860/services/trackbacks/141094.html
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int a[16], k, p;
char path[100];

char ch[] =
{'L', 'U', 'D', 'R'};

int dir[] =
{-1, -4, 4, 1};

int m[16][16] =
{0};

bool go[][4] =
{
0, 0, 1, 1,
1, 0, 1, 1,
1, 0, 1, 1,
1, 0, 1, 0,
0, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 0,
0, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 0,
0, 1, 0, 1,
1, 1, 0, 1,
1, 1, 0, 1,
1, 1, 0, 0,
};


struct point
{
int x, y;


bool operator<(const point & p)const
{
return x < p.x;
}
};


void swap(int i)
{
a[p] = a[p + dir[i]];
a[p += dir[i]] = 0;
}


bool dfs(int step, int mht, int x)
{

if (mht == 0)
{
path[step] = 0;
puts(path);
return 1;
}
int cnt = 0;
point c[4];

for (int i = 0; i < 4; i++)
{
if (!go[p][i] || i == x)continue;
int t = p + dir[i];
c[cnt].x = mht + m[p][a[t] - 1] - m[t][a[t] - 1];
if (c[cnt].x + step <= k)c[cnt++].y = i;
}
sort(c, c + cnt);

for (int i = 0; i < cnt; i++)
{
path[step] = ch[c[i].y];
swap(c[i].y);
if (dfs(step + 1, c[i].x, 3 - c[i].y))return 1;
swap(3 - c[i].y);
}
return 0;
}


int main()
{
for (int i = 0; i < 16; i++)
for (int j = i + 1; j < 16; j++)
m[i][j] = m[j][i] = abs(i / 4 - j / 4) + abs(i % 4 - j % 4);
int T;
scanf("%d", &T);

while (T--)
{
int cnt = 0;

for (int i = 0; i < 16; i++)
{
scanf("%d", &a[i]);
if (a[i] == 0)p = i;
for (int j = 0; j < i; j++)
cnt += a[j] > a[i];
}
if (((cnt + m[p][15])&1) == 0)
puts("This puzzle is not solvable.");

else
{
int mht = 0;
for (int i = 0; i < 16; i++)
if (a[i]) mht += m[i][a[i] - 1];
for (k = mht; k < 51 && !dfs(0, mht, -1); k++);
}
}
return 0;
}

]]> - poj 1011 Stickshttp://www.shnenglu.com/huicpc0860/archive/2010/06/21/118391.htmlhuicpc0860huicpc0860Mon, 21 Jun 2010 14:38:00 GMThttp://www.shnenglu.com/huicpc0860/archive/2010/06/21/118391.htmlhttp://www.shnenglu.com/huicpc0860/comments/118391.htmlhttp://www.shnenglu.com/huicpc0860/archive/2010/06/21/118391.html#Feedback0http://www.shnenglu.com/huicpc0860/comments/commentRss/118391.htmlhttp://www.shnenglu.com/huicpc0860/services/trackbacks/118391.html
//鎼滅儲鍏ラ棬
#include <stdio.h>
#include <algorithm>
using namespace std;
int length,a[64],n,sum;

bool ok,v[64]=
{0};

void dfs(int i,int size,int step)
{
if(size==length)i=0,size=0,step--;
if(step==0)ok=1;
for(int old=-1;!ok&&i<n;i++)

if(!v[i]&&a[i]!=old&&(size+a[i])<=length)
{
v[i]=1;
old=a[i];
dfs(i+1,size+a[i],step);
v[i]=0;
if(size==0)return;
}
}

bool cmp(int x,int y)
{return x>y;}

int main()
{

while(scanf("%d",&n),n)
{
sum=0,ok=0;

for(int i=0;i<n;i++)
{scanf("%d",&a[i]);sum+=a[i];}
sort(a,a+n,cmp);
for(length=a[0];!ok&&length<=sum;length++)

if(sum%length==0)
{
dfs(0,0,(sum/length)-1);
if(ok)printf("%d\n",length);
}
}
return 0;
}

]]>
精品久久久久香蕉网|
久久精品人人做人人爽97|
国产女人aaa级久久久级|
久久这里只有精品视频99|
国产成人精品久久|
久久本道久久综合伊人|
精品亚洲综合久久中文字幕|
国内精品人妻无码久久久影院导航|
久久久久女人精品毛片|
久久精品一区二区影院
|
区亚洲欧美一级久久精品亚洲精品成人网久久久久
|
日韩人妻无码精品久久久不卡
|
国产91久久精品一区二区|
久久久精品国产免大香伊|
亚洲国产综合久久天堂|
99国产欧美精品久久久蜜芽|
伊人 久久 精品|
久久久久亚洲AV成人网|
99久久国产综合精品麻豆|
久久亚洲精品无码aⅴ大香|
久久久久久曰本AV免费免费|
99久久精品费精品国产|
久久午夜综合久久|
青青青国产成人久久111网站|
九九99精品久久久久久|
亚洲AV日韩精品久久久久久久|
久久久久高潮综合影院|
久久青青草原精品国产软件|
国产精品久久成人影院|
久久精品无码午夜福利理论片
|
国产精品久久久久久福利漫画|
少妇人妻综合久久中文字幕|
久久久久国色AV免费看图片|
香港aa三级久久三级|
久久久国产精品网站|
久久96国产精品久久久|
久久国产精品久久久|
国产成人久久精品二区三区|
久久精品国产一区二区三区不卡|
狠狠精品久久久无码中文字幕
|
精品国产青草久久久久福利|