第五個側資點 SE (System Error): 包含 Compile, Runtime 等未定義錯誤均屬於 System Error
哪裡錯了嗎~~~~
public class a981 {
/**
* @param args
*/
static int[] data;
static int n;
static int m;
static boolean isans=false;
static String outans="";
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
n = cin.nextInt();
m = cin.nextInt();
data = new int[n];
for (int i = 0; i < n; i++) {
data[i] = cin.nextInt();
}
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (data[i] > data[j]) {
int temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
isans=false;
outans="";
for(int i=0;i<data.length;i++){
findmaches("",i,0);
}
if(!isans){
System.out.println("-1");
}else{
System.out.print(outans);
}
}
}
private static void findmaches(String outstr, int dataindex,int sum){
if(dataindex<data.length){
outstr=(outstr+data[dataindex]+" ");
sum=sum+data[dataindex];
//System.out.println(outstr.trim());
if(sum>m){
return;
}
if(sum==m)
{
outans+=(outstr.trim())+"\n";
isans=true;
}else{
for(int i=dataindex;i<data.length;i++){
findmaches(outstr,i+1,sum);
}
}
}
}
}