锘??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 鍙戣〃璇勮
]]>
亚洲伊人久久大香线蕉综合图片| 少妇久久久久久被弄到高潮| 精品久久久久久久| 久久精品国产清自在天天线| 伊人色综合久久天天网| 久久ww精品w免费人成| 香蕉久久影院| 国产AⅤ精品一区二区三区久久 | 久久亚洲高清综合| 日韩精品久久无码人妻中文字幕| 久久精品国产欧美日韩| 97精品久久天干天天天按摩| 2021最新久久久视精品爱| 成人亚洲欧美久久久久| 久久成人国产精品二三区| 亚洲综合熟女久久久30p| 欧美性大战久久久久久| 日本三级久久网| 婷婷久久久亚洲欧洲日产国码AV | 久久久久无码精品国产| 亚洲伊人久久综合影院| 久久精品国产99久久香蕉| 99精品伊人久久久大香线蕉| 国产精品久久国产精麻豆99网站| 日韩精品久久无码人妻中文字幕| 国产精品久久新婚兰兰| 天天影视色香欲综合久久| 欧美国产精品久久高清| 久久久这里有精品中文字幕| 久久99精品久久久久久秒播| 国内精品久久久久久久coent| 91精品国产高清久久久久久国产嫩草| 久久久久久亚洲Av无码精品专口| 亚洲AV无码久久| www.久久热.com| 国产免费久久精品丫丫| 四虎久久影院| 久久久久亚洲AV成人片| 成人亚洲欧美久久久久 | 蜜桃麻豆WWW久久囤产精品| 少妇熟女久久综合网色欲|