| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
帮忙看一下问题,谢谢 Compile Error. Problem 1037在本地ECLIPSE里面运行好好的,怎么SUBMIT以后,就COMPILE ERROR了?
谢谢各位大虾指点迷津。。。。
//1037: Decorative Fence.
import java.util.*;
class Fence
{
private int n;
//M[x][n]: the number of fences which have plank 1...n, start with x, have a length of n and the next plank is larger than x.
private long[][] M;
private long[][] W;
private boolean[] flag;
private boolean print;
Fence(int N)
{
n = N;
M = new long[n+1][n+1];
W = new long[n+1][n+1];
flag = new boolean[n+1];
for(int i=1; i<=n; i++)
for(int j=1; j <= n; j++)
{
M[i][j] = 0;
W[i][j] = 0;
}
for(int i=1; i<=n; i++)
flag[i] = false;
print = false;
}
private void setupMatrix()
{
M[1][1] = 1; W[1][1] = 1;
W[1][2] = 0; M[1][2] = 1;
W[2][2] = 1; M[2][2] = 0;
for(int j=3; j <= n; j++)
for(int i=1; i <= n; i++)
{
for(int k=i; k<j; k++)
M[i][j] += W[k][j-1];
for(int k=1; k<i; k++)
W[i][j] += M[k][j-1];
}
}
private void findplank(int k, int m){
for (int i = 1; i <= m; i++)
if (flag[i] && i <= k){
k++; m++;
}
flag[k] = true;
if (print) System.out.print(" "+k);
else{
System.out.print(k);
print = true;
}
}
private void produceResults(long c){
int k = 1;
print = false;
boolean direct = true, first = true;
while(n!=0){
if (direct)
if (c > W[k][n]){
c -= W[k++][n];
if (first) {direct = false; k--;}
}else{
findplank(k, n--);
first = false;
direct = false;
k = 1;
}
else
if (c > M[k][n]){
c -= M[k++][n];
if (first) direct = true;
}else{
findplank(k, n--);
first = false;
direct = true;
}
}
System.out.println();
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t, N;
long C;
t=sc.nextInt();;
while((t--)!=0){
N=sc.nextInt();
C=sc.nextLong();
Fence m = new Fence(N);
m.setupMatrix();
m.produceResults(C);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator