Mais conteúdo relacionado
Semelhante a 金大アルゴリズム勉強会#002資料 (6)
Mais de Takumi Murano (10)
金大アルゴリズム勉強会#002資料
- 8. 全パターン調べてみた
public static double calcMax(int count,
ArrayList<Integer> remainder, double result) {
if (count == k) {
return result;
}
double maxResult = 0;
for (int i = 0; i < remainder.size(); i++) {
ArrayList<Integer> tmpRem = new ArrayList<>(remainder);
double tmpResult = ((tmpRem.get(i) + result) / 2.0);
tmpRem.remove(i);
maxResult = Math.max(maxResult,
calcMax(count + 1, tmpRem, tmpResult));
}
return maxResult;
}
- 11. ちなみに
• N = 100, K = 100 のとき 100! パターン
• N = 12, K = 12 のとき約34秒
• 100! = 9.3 * 10^157, 12! = 4.8 * 10^8
• この場合にかかる時間は単純計算で…