FerrishTheFish
Smash Ace
I said a week, but I got bored and I love programming, so here is the console app version (C++) with some primitive error handling. Copy-paste it into your favorite environment. Hell, OS, stick it in the OP if you feel like it.
[COLLAPSE="Pools Only C++"]#include <iostream>
using namespace std;
int gcd(int,int); // Finds the greatest common divisor
int main()
{
int n, // Total number of players
x, // Number of paid players
y, // Ideal number of R2 players
p, // Number of R1 pools
m, // Number of players per R1 pool
a, // Number of players who advance per R1 pool
j; // Number of pools with extra player(s)
char s = 'N';
cout << "How many total players? ";
cin >> n;
cout << "How many paid players? ";
cin >> x;
n = abs(n); // Handles negative numbers
x = abs(x);
y = x;
while (y*2 <= n) // Find the largest value of y less than n
{
y = y*2;
}
if (y == n) // If the largest value of y is n,
{
cout << "\nYou have an ideal number of players.\n\n";
}
else
{
do
{
int pools = 1, // Initialize local variables
men = n,
adv = 0;
p = 1; // Set or reset global variables
m = n;
a = 0;
for (int i = 0; i < n; i++) // Check every possible pool configuration
{
pools = gcd((n-i),y);
men = n/pools;
adv = y/pools;
// Save the best configuration
if (men < m && men > 2 && adv != men && adv != 1)
{
m = men;
p = pools;
a = adv;
}
}
j = n - (n/p)*p; // Calculate the "extra" players
cout << "\nIdeal number of R2 players: " << y << endl << endl;
cout << n << " players in " << p << " pools of " << m << " players each (" << j << " with " << m+1 << " players), top " << a << " advance: ";
cout << y << " players remain." << endl;
cout << "\nIs this acceptable? (Y/N) ";
cin >> s;
if (s != 'Y' && s != 'y')
{
y = y/2;
}
}while (s != 'Y' && s != 'y' && y != x/2);
}
if (y == x/2)
{
cout << "\nYou are impossible to please!\n\n";
}
system("PAUSE");
return 0;
}
int gcd(int a,int b)
{
if (a == b)
{
return a;
}
else if (a > b)
{
return gcd((a-b),a);
}
else
{
return gcd(a,(b-a));
}
}[/COLLAPSE]##!!IMPORTANT!!##
When it's done with its calculations, the program will ask you, "Is this acceptable? (Y/N)"
There are TWO circumstances in which you should type in "N":
1) If the program tells you that zero players should advance per pool, OR
2) If the program tells you to make really big pools.
The first is a fail-safe. For the non-programmers out there, I tell the computer that zero players should advance from round 1, and I only allow the program to change that number if it finds something better than 1 gigantic pool with everybody in it.
The second is just kind of common sense.
I still want $20 for the Java version 
[COLLAPSE="Pools Only C++"]#include <iostream>
using namespace std;
int gcd(int,int); // Finds the greatest common divisor
int main()
{
int n, // Total number of players
x, // Number of paid players
y, // Ideal number of R2 players
p, // Number of R1 pools
m, // Number of players per R1 pool
a, // Number of players who advance per R1 pool
j; // Number of pools with extra player(s)
char s = 'N';
cout << "How many total players? ";
cin >> n;
cout << "How many paid players? ";
cin >> x;
n = abs(n); // Handles negative numbers
x = abs(x);
y = x;
while (y*2 <= n) // Find the largest value of y less than n
{
y = y*2;
}
if (y == n) // If the largest value of y is n,
{
cout << "\nYou have an ideal number of players.\n\n";
}
else
{
do
{
int pools = 1, // Initialize local variables
men = n,
adv = 0;
p = 1; // Set or reset global variables
m = n;
a = 0;
for (int i = 0; i < n; i++) // Check every possible pool configuration
{
pools = gcd((n-i),y);
men = n/pools;
adv = y/pools;
// Save the best configuration
if (men < m && men > 2 && adv != men && adv != 1)
{
m = men;
p = pools;
a = adv;
}
}
j = n - (n/p)*p; // Calculate the "extra" players
cout << "\nIdeal number of R2 players: " << y << endl << endl;
cout << n << " players in " << p << " pools of " << m << " players each (" << j << " with " << m+1 << " players), top " << a << " advance: ";
cout << y << " players remain." << endl;
cout << "\nIs this acceptable? (Y/N) ";
cin >> s;
if (s != 'Y' && s != 'y')
{
y = y/2;
}
}while (s != 'Y' && s != 'y' && y != x/2);
}
if (y == x/2)
{
cout << "\nYou are impossible to please!\n\n";
}
system("PAUSE");
return 0;
}
int gcd(int a,int b)
{
if (a == b)
{
return a;
}
else if (a > b)
{
return gcd((a-b),a);
}
else
{
return gcd(a,(b-a));
}
}[/COLLAPSE]##!!IMPORTANT!!##
When it's done with its calculations, the program will ask you, "Is this acceptable? (Y/N)"
There are TWO circumstances in which you should type in "N":
1) If the program tells you that zero players should advance per pool, OR
2) If the program tells you to make really big pools.
The first is a fail-safe. For the non-programmers out there, I tell the computer that zero players should advance from round 1, and I only allow the program to change that number if it finds something better than 1 gigantic pool with everybody in it.
The second is just kind of common sense.