import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; import java.util.function.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.awt.geom.*; import javax.imageio.*; import java.math.*; import java.time.Duration; // converts the index of a correct guess in a probabilistic // list to a score between 0 and 1 // properties: // -index 0 gets score 1 // -higher indices get lower scores // -index -1 (not found) gets score 0 class main { static double scoreForIndexInProbabilisticList(int index) { return index < 0 ? 0 : distanceToProbability(index); } // properties: // -yields a proper probability (0 < p <= 1) // -distance 0 has probability 1 // -function is monotonically decreasing // (greater distance = lower probability) // -negative distances are interpreted as positive static double distanceToProbability(double distance) { return genericDistanceToProbability(distance); } static double distanceToProbability(double a, double b) { return genericDistanceToProbability(a, b); } // properties: // -yields a proper probability (0 < p <= 1) // -distance 0 has probability 1 // -function is monotonically decreasing // (greater distance = lower probability) // -negative distances are interpreted as positive static double genericDistanceToProbability(double distance) { return 1/(1+abs(distance)); } static double genericDistanceToProbability(double a, double b) { return genericDistanceToProbability(a-b); } static float abs(float f) { return Math.abs(f); } static int abs(int i) { return Math.abs(i); } static double abs(double d) { return Math.abs(d); } }