public string SolveOneCase(InputParser input) { int N = input.GetInt(); double V = double.Parse(input.GetString()); double X = double.Parse(input.GetString()); double R0 = double.Parse(input.GetString()); double C0 = double.Parse(input.GetString()); if (N == 1) { if (C0 != X) { return(IMPOSSIBLE); } else { return((V / R0).ToString()); } } double R1 = double.Parse(input.GetString()); double C1 = double.Parse(input.GetString()); if (C0 < X && C1 < X) { return(IMPOSSIBLE); } if (C0 > X && C1 > X) { return(IMPOSSIBLE); } if (X == C0 || X == C1) { double r = 0; if (X == C0) { r += R0; } if (X == C1) { r += R1; } return((V / r).ToString()); } var v0 = V * (X - C1) / (C0 - C1); var v1 = V - v0; var t0 = v0 / R0; var t1 = v1 / R1; var res = Math.Max(t0, t1); return(res.ToString()); }
public string SolveOneCase(InputParser input) { var word = input.GetString(); int n = input.GetInt(); int count = 0; for (int i = 0; i < word.Length; i++) { for (int j = i + n - 1; j < word.Length; j++) { int c = 0; var sub = word.Substring(i, j - i + 1); for (int k = 0; k < sub.Length; k++) { if (IsConst(sub[k])) { c++; } else { c = 0; } if (c == n) { //Console.WriteLine(sub); count++; break; } } } } return(count.ToString()); }
public string SolveOneCase(InputParser input) { int K = input.GetInt(); int L = input.GetInt(); int S = input.GetInt(); string alph = input.GetString(); string word = input.GetString(); // not in alphabet for (int i = 0; i < L; i++) { var c = word[i]; if (!alph.Contains(c.ToString())) { return("0.0"); } } // all same bool same = true; var a = word[0]; for (int i = 0; i < L; i++) { if (word[i] != a) { same = false; } } for (int i = 0; i < K; i++) { if (alph[i] != a) { same = false; } } if (same) { return("0.0"); } int overlap = 0; for (int i = 1; i < L; i++) { var st = word.Substring(0, i); var e = word.Substring(word.Length - i, i); if (st == e) { overlap = i; } } int count = 0; int ii = 0; while (true) { if (ii + L <= S) { count++; ii = ii + L - overlap; continue; } break; } double p = 1; for (int i = 0; i < L; i++) { var aa = word[i]; double cc = alph.Count(x => x == aa); p *= cc / K; } var res = count - p * (S - L + 1); return(res.ToString()); }