锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久综合久久综合久久,亚洲AV伊人久久青青草原,久久99国产精品久久http://m.shnenglu.com/huicpc0860/category/14095.htmlEverything has its history.zh-cnFri, 04 Mar 2011 11:39:46 GMTFri, 04 Mar 2011 11:39:46 GMT60uva 10181 15-Puzzle Problemhttp://m.shnenglu.com/huicpc0860/archive/2011/03/04/141094.htmlhuicpc0860huicpc0860Fri, 04 Mar 2011 02:00:00 GMThttp://m.shnenglu.com/huicpc0860/archive/2011/03/04/141094.htmlhttp://m.shnenglu.com/huicpc0860/comments/141094.htmlhttp://m.shnenglu.com/huicpc0860/archive/2011/03/04/141094.html#Feedback0http://m.shnenglu.com/huicpc0860/comments/commentRss/141094.htmlhttp://m.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-441};
int m[16][16= {0};
bool go[][4= {
    
0011,
    
1011,
    
1011,
    
1010,
    
0111,
    
1111,
    
1111,
    
1110,
    
0111,
    
1111,
    
1111,
    
1110,
    
0101,
    
1101,
    
1101,
    
1100,
}
;

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


huicpc0860 2011-03-04 10:00 鍙戣〃璇勮
]]>
poj 1011 Stickshttp://m.shnenglu.com/huicpc0860/archive/2010/06/21/118391.htmlhuicpc0860huicpc0860Mon, 21 Jun 2010 14:38:00 GMThttp://m.shnenglu.com/huicpc0860/archive/2010/06/21/118391.htmlhttp://m.shnenglu.com/huicpc0860/comments/118391.htmlhttp://m.shnenglu.com/huicpc0860/archive/2010/06/21/118391.html#Feedback0http://m.shnenglu.com/huicpc0860/comments/commentRss/118391.htmlhttp://m.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;
}

        
        


huicpc0860 2010-06-21 22:38 鍙戣〃璇勮
]]>
久久久久久久久久久精品尤物| 狠狠色丁香婷婷久久综合五月 | 国产无套内射久久久国产| 婷婷综合久久中文字幕蜜桃三电影| A狠狠久久蜜臀婷色中文网| 国产高潮久久免费观看| 久久大香萑太香蕉av| 一本大道加勒比久久综合| 久久国内免费视频| MM131亚洲国产美女久久| 亚洲精品乱码久久久久久不卡| 久久婷婷成人综合色综合| 国产精品无码久久久久| 久久综合精品国产二区无码| 狠狠精品干练久久久无码中文字幕 | 99久久亚洲综合精品成人| 亚洲精品国产第一综合99久久 | 久久本道综合久久伊人| 亚洲欧美日韩久久精品第一区| 久久久久久A亚洲欧洲AV冫 | 亚洲精品无码久久毛片| 色综合久久中文综合网| 无码人妻精品一区二区三区久久久| 久久人人爽人人精品视频| 丰满少妇人妻久久久久久4| 精品久久久无码人妻中文字幕豆芽| 2021国内久久精品| 日韩十八禁一区二区久久| 久久久久久久国产免费看| 久久精品一区二区影院| 久久久久久免费一区二区三区 | 亚洲狠狠婷婷综合久久蜜芽| 久久亚洲精品国产精品婷婷 | 97久久国产亚洲精品超碰热 | 久久伊人精品青青草原高清| 久久久久亚洲AV无码专区体验| 无遮挡粉嫩小泬久久久久久久| 中文字幕乱码人妻无码久久| 午夜精品久久久久久毛片| 久久一日本道色综合久久| 久久香蕉超碰97国产精品|