锘??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;
}

]]>
亚洲午夜精品久久久久久app|
国产精品久久久久蜜芽|
久久精品国产网红主播|
久久青青草原精品影院|
精品久久久久久99人妻|
久久人人添人人爽添人人片牛牛|
久久久久久久91精品免费观看
|
亚洲欧美伊人久久综合一区二区|
亚洲国产精品高清久久久|
久久精品国产半推半就|
亚洲国产成人久久综合区|
精品午夜久久福利大片|
三级韩国一区久久二区综合
|
久久免费高清视频|
久久久久免费精品国产|
99精品伊人久久久大香线蕉|
亚洲日本久久久午夜精品|
99久久99久久精品国产|
久久精品国产第一区二区三区|
久久亚洲电影|
精品久久久久久无码国产|
日韩精品久久无码人妻中文字幕|
中文字幕一区二区三区久久网站|
中文国产成人精品久久不卡|
精品国产综合区久久久久久|
好属妞这里只有精品久久|
亚洲中文字幕无码久久综合网|
久久久久亚洲精品中文字幕|
四虎国产永久免费久久|
97r久久精品国产99国产精|
亚洲精品蜜桃久久久久久|
日批日出水久久亚洲精品tv|
国产精品免费久久久久久久久|
久久夜色精品国产欧美乱|
亚洲国产精品无码久久一线|
亚洲国产高清精品线久久
|
久久无码高潮喷水|
蜜桃麻豆WWW久久囤产精品|
久久天天躁夜夜躁狠狠躁2022|
久久亚洲精品无码播放|
日本加勒比久久精品|