1.
package contestVolumes.volume113;
import java.util.Scanner;
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11346 - Probability
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2321
*
* @author Siegfried Ippisch
* @version 1.0
*
* Method : Integration
* Status : Accepted
* Runtime: 0.252
*/
public class Probability {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
while(n-- > 0){
System.out.printf("%.6f%%%n",probability(in.nextDouble(),in.nextDouble(),in.nextDouble()));
}
in.close();
}
private static double probability(double a, double b, double s) {
if(s == 0)
return 100;
double all = a*b;
if(s > all)
return 0;
double x0 = s/b;
double greater = s*(Math.log(x0/a)) + b*(a-x0);
return 100*greater/all;
}
}
2.
package acm_11346_probability;
/**
* FWP, Ausgew¦hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: acm_11346_probability
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2321
*
* @author Martin Lambeck
* @version 1.0, 10.08.2010
*
* Method : stochastik
* Status : Accepted
* Runtime: 0.208
*/
import java.util.Scanner;
public class Main
{
static Scanner sc = new Scanner(System.in);
public static void main(String... args)
{
int cases = sc.nextInt();
for (int i = 0; i < cases; i++)
System.out.printf("%.6f%%%n", testcase());
}
public static double testcase()
{
double a,b,s;
double p;
a = sc.nextDouble();
b = sc.nextDouble();
s = sc.nextDouble();
if (a*b <= s)
return 0.0;
if (s == 0)
return 100.0;
//zero = s/b
//area = º (b-s/x) FOR x = [zero; a]
// => area = [x * b - s ln(x)] FOR x1 = zero, x2 = a
// => area = (a*b - s*ln(x)) - (zero*b - s*ln(x)) = ...
// p = 1 - area / totalarea = area / (a*b) = ... = 1 + (s * (ln(s / (a*b)) - 1) / (a*b)
p = 1.0 + (s * (Math.log(s / (a * b)) - 1.0)) / (a*b);
p *= 100.0;
return p;
}
}
3.
/**
* ACM Training 2009
* ACM Problem #11346 - Probability
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2321
*
* @author Felix Dietrich
* @version 1.0, 12/03/2009
*
* Methode:
* Status : Accepted
* Runtime: 0.212
*/
import java.util.Scanner;
class Main
{
public static void main(String... s)
{
Scanner sc = new Scanner(System.in);
int testcases = sc.nextInt();
double a, b, S;
double x0;
for (int i = 0; i < testcases; i++)
{
a = sc.nextDouble();
b = sc.nextDouble();
S = sc.nextDouble();
x0 = S/b;
if (a*b <= S)
System.out.println(String.format("%.06f", 0.0) + "%");
else if (Math.abs(S) < 1e-6)
System.out.println(String.format("%.06f", 100.0) + "%");
else
System.out.println(String.format("%.06f", 100*(a*b-x0*b-S*Math.log(a/x0)) / (a*b)) + "%");
}
}
}
4.
/**
* ACM Training, WS09/10
* ACM Problem #11346 Probability
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2321
*
* @author Doina Logofatu
* @version 1.0, 12/03/2009
*
* Methode: Math, Probability
* Status : Accepted
* Runtime: 0.008
*/
#include <stdio.h>
#include <math.h>
int main(){
int n;
double a, b, S;
double x0, P;
scanf("%d", &n);
while(n--){
scanf("%lf%lf%lf", &a, &b, &S);
x0 = S/b;
if(a*b<=S) P = 0;
else
if(S>0) P = ((a-x0)*b-S*log(a/x0))/(a*b)*100;
else P=100.;
printf("%.6lf%%\n", P);
}
return 0;
}