1. 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);

}
}