-
Notifications
You must be signed in to change notification settings - Fork 0
/
introductionToRandomStrings.java
104 lines (102 loc) · 3.09 KB
/
introductionToRandomStrings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.io.*;
import java.util.*;
import java.math.*;
/******************************\
* The solution is at the top *
* *
* Created by : azhar556 *
\******************************/
public class B {
static class Task {
public void solve() {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int GC = 0;
int AT = 0;
for (char c : s.toCharArray()) if (c == 'G' || c == 'C') GC++; else AT++;
while (sc.hasNext()) {
double gcContent = Double.parseDouble(sc.next());
out.printf("%.3f\n", Math.log10(Math.pow(gcContent / 2, GC) * Math.pow((1 - gcContent) / 2, AT)));
}
}
}
public static void main(String[] args) {
long time = System.currentTimeMillis();
int t;// = in.readInt();
t = 1;
Task solver = new Task();
while (t-- > 0) solver.solve();
err.println("Time elapsed : " + (System.currentTimeMillis() - time) / 1000F + " s.");
err.close(); out.close();
}
static Util util = new Util();
static class Util {
public void swap (int[] arr, int a, int b) {int save = arr[a]; arr[a] = arr[b]; arr[b] = save;}
public int[] nextPermutation (int[] arr) {
int n = arr.length;
int pvt = n - 2;
while (pvt >= 0 && arr[pvt] >= arr[pvt + 1]) pvt--;
if (pvt < 0) return arr;
for (int i = n - 1; i > pvt; i--) {
if (arr[i] > arr[pvt]) {
util.swap(arr, i, pvt); break;
}
}
for (int i = 0; i < n / 2; i++) {
util.swap(arr, pvt + 1, pvt + (n - 1 - i));
}
return arr;
}
public int[] radixSort (int[] f) {
int n = f.length;
int[] to = new int[n];
{
int[] b = new int[65537];
for (int i = 0;i < n;i++) b[1+(f[i]&0xffff)]++;
for (int i = 1;i <= 65536;i++) b[i] += b[i-1];
for (int i = 0;i < n;i++) to[b[f[i]&0xffff]++] = f[i];
int[] d = f; f = to;to = d;
}
{
int[] b = new int[65537];
for (int i = 0;i < n;i++) b[1+(f[i]>>>16)]++;
for (int i = 1;i <= 65536;i++) b[i] += b[i-1];
for (int i = 0;i < n;i++) to[b[f[i]>>>16]++] = f[i];
int[] d = f; f = to;to = d;
}
return f;
}
}
static InputReader in = new InputReader();
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static PrintWriter err = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err)));
static class InputReader {
private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private StringTokenizer token;
public String read() {
while (token == null || !token.hasMoreTokens()) {
try {
token = new StringTokenizer(br.readLine());
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
return token.nextToken();
}
public char readChar() {
return Character.valueOf(read().charAt(0));
}
public int readInt() {
return Integer.parseInt(read());
}
public double readDouble() {
return Double.parseDouble(read());
}
public long readLong() {
return Long.parseLong(read());
}
}
}
// Collections Arrays Math
// Vector HashSet TreeSet HashMap TreeMap ArrayDeque