This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' | |
typedef long long ll; | |
typedef vector<ll> vll; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int v, c, o, n; | |
while(scanf("%d %d %d\n", &v, &c, &o) == 3) { | |
n = c + v; | |
double answ = (c * (c - 1)) / (n * (n - o - 1) * 1.0); | |
answ += (c * v * 1.0) / (n * (n - o - 1)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Solution using Floyd's Tortoise and Hare Algorithm | |
**/ | |
#include <bits/stdc++.h> | |
using namespace std; | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
template <class T> int size(const T &x) {return x.size();} | |
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;} | |
#define F first | |
#define S second | |
#define PB push_back | |
#define endl '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''''Maximum Subarray Problem - Extended Kadane | |
Source: https://www.quora.com/How-do-I-solve-maximum-product-subarray-problems | |
''' | |
def max_product(A): | |
maxG, maxC, minC = A[0], A[0], A[0] | |
for num in A: | |
temp = maxC | |
maxC = max([num, temp * num, minC * num]) |