public final class knapsack {
class NimotuDef {
String Name;
int KG;
int Val;
boolean willOut;
NimotuDef(String Name,int KG,int Val){
this.Name = Name;
this.Val = Val;
this.KG = KG;
}
};
//対象データ
NimotuDef NimotuArr[] = new NimotuDef[5];
public static void main(String[] args) {
knapsack mi = new knapsack();
mi.main();
}
void main() {
NimotuArr[0] = new NimotuDef("A",3, 4);
NimotuArr[1] = new NimotuDef("B",4, 5);
NimotuArr[2] = new NimotuDef("C",5, 6);
NimotuArr[3] = new NimotuDef("D",6, 7);
NimotuArr[4] = new NimotuDef("E",9,10);
int UPB = NimotuArr.length-1;
int SumKG,SumVal;
String Nimotus;
for (int A=0;A<=1;A++)
for (int B=0;B<=1;B++)
for (int C=0;C<=1;C++)
for (int D=0;D<=1;D++)
for (int E=0;E<=1;E++){
SumKG = SumVal = 0;
Nimotus = "";
if (A==1){ Nimotus +="A"; SumKG+= NimotuArr[0].KG; SumVal+= NimotuArr[0].Val;}
if (B==1){ Nimotus +="B"; SumKG+= NimotuArr[1].KG; SumVal+= NimotuArr[1].Val;}
if (C==1){ Nimotus +="C"; SumKG+= NimotuArr[2].KG; SumVal+= NimotuArr[2].Val;}
if (D==1){ Nimotus +="D"; SumKG+= NimotuArr[3].KG; SumVal+= NimotuArr[3].Val;}
if (E==1){ Nimotus +="E"; SumKG+= NimotuArr[4].KG; SumVal+= NimotuArr[4].Val;}
if (SumKG <= 15 && (A+B+C+D+E !=0))
System.out.println(Nimotus + " SumKG=" + Integer.toString(SumKG)
+ " SumVal=" + Integer.toString(SumVal));
}
}
}