1. C++, Andreas Kunft

/*
 * ACM Programming Contest
 * Problem: 11466
 * Status: Accepted
 * Language: C++
 * Runtime: 0.110
 * Date: 2009-04-01 17:32:23
 * Author: Andreas Kunft
 */
#include <iostream>

using namespace std;

long long getMaxPrime(long long number) {
long long j, a = 2;
int prime = 0;
if (number <= 2)
return -1;
if (number % 2 == 0) {
prime++;
while (number % 2 == 0)
number /= 2;
}
if (number == 1)
return -1;
for (j = 3; number != 1 && j * j <= number; j += 2) {
if (number % j == 0) {
prime++;
while (number % j == 0)
number /= j;
a = j;
}
}
if (prime == 0)
return -1;
if (prime == 1 && number == 1)
return -1;
if (number > 1)
return number;
return a;
}

int main() {
long long n;
while (scanf("%lld", &n) == 1 && n != 0) {
if (n < 0) n *= -1;
printf ("%lld\n", getMaxPrime(n));
}
return 0;
}