package p4;
public class pro {
int[][] delta=new int[400][21];
int number_delta;
int[] pol=new int[21];
int number_pol;
int[][] a=new int[101][101];
int[][] alpha=new int[400][21];
int number_alpha;
int k,k2;
public static void main(String[] args) {
pro test=new pro();
}
pro(){
k=60;
k2=2;
fast sub=new fast();
sub.k2=k2;
sub.k=k;
sub.makedata();
delta=sub.delta;
number_delta=sub.number_delta;
int s,tx,sx,c;
for(c=2;c<21;c++){
tx=0;
for(s=1;s<number_delta+1;s++){
tx=tx+1;
for(sx=1;sx<c;sx++){
alpha[tx][sx]=delta[s][sx];
}
alpha[tx][c]=1;
tx=tx+1;
for(sx=1;sx<c;sx++){
alpha[tx][sx]=delta[s][sx];
}
alpha[tx][c]=2;
}
number_alpha=tx;
int tr;
number_delta=0;
for(tr=1;tr<number_alpha+1;tr++){
for(s=1;s<c+1;s++){
pol[s]=alpha[tr][s];
}
box sub3=new box();
sub3.number_pol=c;
sub3.pol=pol;
sub3.k=k;
sub3.makedata();
a=sub3.a;
int ch=check();
if(ch>50){
number_delta=number_delta+1;
for(s=1;s<c+1;s++){
delta[number_delta][s]=pol[s];
}
}
}
}
}
int check(){
int s,sx,n;
n=0;
for(s=1;s<k2+1;s++){
for(sx=1;sx<k+1;sx++){
if(a[s][sx]>60)n=n+1;
}}
int ch=0;
if(n==number_pol*6)ch=100;
return ch;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package p4;
public class fast{
int[][] delta=new int[400][21];
int number_delta;
int[] pol=new int[21];
int number_pol;
int[][] a=new int[101][101];
int k,k2;
void makedata(){
number_pol=1;
pol[1]=1;
box sub=new box();
sub.number_pol=number_pol;
sub.k=k;
sub.pol=pol;
sub.makedata();
a=sub.a;
int ch=check();
if(ch>50){
number_delta=number_delta+1;
delta[number_delta][1]=1;
}
number_pol=1;
pol[1]=2;
box sub2=new box();
sub2.number_pol=number_pol;
sub2.k=k;
sub2.pol=pol;
sub2.makedata();
a=sub2.a;
ch=check();
if(ch>50){
number_delta=number_delta+1;
delta[number_delta][1]=2;
}
}
int check(){
int s,sx,n;
n=0;
for(s=1;s<k2+1;s++){
for(sx=1;sx<k+1;sx++){
if(a[s][sx]>60)n=n+1;
}}
int ch=0;
if(n==number_pol*6)ch=100;
return ch;
}
package p4;
public class box {
int cx,cy;
int[] pol=new int[21];
int[][] a=new int[100][100];
int k;
int number_pol;
void makedata(){
int s;
int sx;
for(s=1;s<90;s++){
for(sx=1;sx<90;sx++){
a[s][sx]=0;
}
}
int tr;
for(tr=1;tr<number_pol+1;tr++){
search();
if(pol[tr]==1)stepx();
if(pol[tr]==2)stepy();
}
}
void search(){
int s,sx,h;
int miny=999;
for(s=1;s<90;s++){
for(sx=1;sx<90;sx++){
h=0;
if(a[s][sx]<50)h=h+1;
if(s<miny)h=h+1;
if(sx>k)h=0;
if(h==2)miny=s;
}
}
int minx=9999;
for(sx=1;sx<90;sx++){
h=0;
if(a[miny][sx]<50)h=h+1;
if(sx<minx)h=h+1;
if(sx>k)h=0;
if(h==2)minx=sx;
}
cx=minx;
cy=miny;
}
void stepx(){
a[cy][cx]=100;
a[cy][cx+1]=100;
a[cy][cx+2]=100;
a[cy+1][cx]=100;
a[cy+1][cx+1]=100;
a[cy+1][cx+2]=100;
}
void stepy(){
a[cy][cx]=100;
a[cy+1][cx]=100;
a[cy+2][cx]=100;
a[cy][cx+1]=100;
a[cy+1][cx+1]=100;
a[cy+2][cx+1]=100;
}
}
最終更新:2015年10月24日 09:53