1.

package streetNumbers;
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 138 Street Numbers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=74
*
* @author Patrick Bédat
* @version 1.0, 10/31/2010
*
* Method : Gauþsche Summenformel
* Status : Accepted
* Runtime: 1.080
*/
public class Main
{

public static void main(String... args)
{
generateNumbers();
}

private static void generateNumbers()
{
long sumBefore = 1;
int count = 0;

for (int i = 2; count < 10; i++)
{
//fake determinant, missing division by 2
Double determinant = Math.sqrt(1 + 8*(sumBefore*2+i));

if(determinant - determinant.intValue() == 0)
{
count++;

int result = ((int)(determinant-1))>>1;
System.out.printf("%10d%10d%n",i,result);
}

sumBefore += i;
}
}
}



2. Martin Lambeck


package acm_138_street_numbers;

public class Main
{
public static void main (String...args)
{
int found = 0;
long start = 1;
long end;

System.out.println("6: " + find(6));

while (found < 10)
{
start++;
end = find(start);

if (end != 0)
System.out.println("" + start + " - " + end);
}
}

static long sum (long n)
{
return (n * (n+1)) / 2;
}

static long find(long nr)
{
long togo = sum(nr);
long n = nr-1;

while (togo > 0)
{
n++;
togo -= n;
}

return (togo == 0 ? n : 0);
}
}

2.

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #138 (Street Numbers)
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=74
*
* @author David Leib
* @author Julius Tschannerl
* @version 1.0, 03/25/2009
*
* Status : Accepted
* Runtime: 2.3
*/
public class Main {

public static void main(String... args)
{
int outputCount = 1;
long sumBelow = 0;
long end = 2;
long sumAbove = 0;


for (long i = 2; outputCount <= 10; i++)
{
sumBelow += (i-1);
sumAbove -= (i);
for (long j = (end+1); sumAbove < sumBelow; end++)
{
sumAbove += end;
}
if (sumAbove == sumBelow){
System.out.printf("%10d%10d%n", i, end-1);
outputCount++;
}

}
System.exit(0);

}
}