1. 

/**
* ACM Problem 209 - Triangular Vertices
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=4&page=show_problem&problem=145
*
* @author Miesel Christoph
* @version 2.0, 05/07/2009
* Status : Accepted
* Runtime: 0.880
*/

import java.io.*;
import java.util.*;

public class TriangularVertices
{
static int[] triangle(int a, int b, int c)
{
int[] array = new int[] {a, b, c};
Arrays.sort(array);
return array;
}

static int[] para(int a, int b, int c, int d)
{
int[] array = new int[] {a, b, c, d};
Arrays.sort(array);
return array;
}

static int[] hexagon(int a, int b, int c, int d, int e, int f)
{
int[] array = new int[] {a, b, c, d, e, f};
Arrays.sort(array);
return array;
}

public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
StringTokenizer token = new StringTokenizer(line);
int counter = 1;
int x1=0,x2=0,x3=0,x4=0,x5=0,x6=0;

while(line != null)
{
token = new StringTokenizer(line);
while(token.hasMoreTokens())
{
switch(counter)
{
case 1: {x1 = Integer.parseInt(token.nextToken()); counter++; break;}
case 2: {x2 = Integer.parseInt(token.nextToken()); counter++; break;}
case 3: {x3 = Integer.parseInt(token.nextToken()); counter++; break;}
case 4: {x4 = Integer.parseInt(token.nextToken()); counter++; break;}
case 5: {x5 = Integer.parseInt(token.nextToken()); counter++; break;}
case 6: {x6 = Integer.parseInt(token.nextToken()); counter++; break;}
default: break;
}

}

// counter ist hier genau um 1 zu hoch!!!!!!!

switch(counter)
{
case 4: //Dreieck
{
int n1 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x1));
int n2 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x2));
int n3 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x3));
int[] tests = triangle(n1,n2,n3);
int[] points = triangle(x1,x2,x3);

if(tests[0]==tests[1] && tests[0] != tests[2])
{
int diff = points[1]-points[0];

if(diff==(tests[2]-tests[1]) && points[2] == 0.5*tests[2]*(tests[2]+1)-(0.5*tests[1]*(tests[1]+1)-points[1])-diff)
System.out.println(x1+" "+x2+" "+x3+" are the vertices of a triangle");
else System.out.println(x1+" "+x2+" "+x3+" are not the vertices of an acceptable figure");
}
else if(tests[1]==tests[2] && tests[1] != tests[0])
{
int diff = points[2]-points[1];

if(diff==(tests[1]-tests[0]) && points[1]== 0.5*tests[2]*(tests[2]+1)-(0.5*tests[0]*(tests[0]+1)-points[0])-diff)
System.out.println(x1+" "+x2+" "+x3+" are the vertices of a triangle");
else System.out.println(x1+" "+x2+" "+x3+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" are not the vertices of an acceptable figure");
break;
}
case 5: // Parallelogramm
{
int n1 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x1));
int n2 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x2));
int n3 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x3));
int n4 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x4));
int[] tests = para(n1,n2,n3,n4);
int[] points = para(x1,x2,x3,x4);

if(tests[1]==tests[0])
{
int diff = points[1]-points[0];
if(diff==points[3]-points[2]&&diff==tests[3]-tests[1]&&diff==tests[2]-tests[1] && diff!=0)
{
if((0.5*tests[1]*(tests[1]+1)-points[1]==0.5*tests[3]*(tests[3]+1)-diff-points[3]) || (0.5*tests[1]*(tests[1]+1)-points[1]==0.5*tests[3]*(tests[3]+1)-points[3]))
{
System.out.println(x1+" "+x2+" "+x3+" "+x4+" are the vertices of a parallelogram");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" are not the vertices of an acceptable figure");
}
else
{
if(tests[1]==tests[2])
{
int diff = points[2]-points[1];
if(2*diff==tests[3]-tests[0]&&tests[1]-tests[0]==diff&&diff==tests[3]-tests[2]&&diff!=0)
{
if(0.5*tests[0]*(tests[0]+1)-points[0]==0.5*tests[2]*(tests[2]+1)-points[2] && 0.5*tests[0]*(tests[0]+1)-points[0]==0.5*tests[3]*(tests[3]+1)-points[3]-diff)
{
System.out.println(x1+" "+x2+" "+x3+" "+x4+" are the vertices of a parallelogram");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" are not the vertices of an acceptable figure");
}
break;
}
case 7: // Hexagon
{
int n1 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x1));
int n2 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x2));
int n3 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x3));
int n4 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x4));
int n5 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x5));
int n6 = (int)Math.ceil(-0.5+0.5*Math.sqrt(1+8*x6));

int[] points = hexagon(x1,x2,x3,x4,x5,x6);
int[] tests = hexagon(n1,n2,n3,n4,n5,n6);


if(tests[1]==tests[0])
{
int diff = points[1]-points[0];
if(diff==tests[2]-tests[0]&&tests[3]-tests[1]==diff&&tests[5]-tests[3]==diff&&tests[4]-tests[2]==diff&&points[5]-points[4] ==diff&&points[3]-points[2]==2*diff && diff!=0)
{
if(0.5*tests[1]*(tests[1]+1)-points[1]==0.5*tests[3]*(tests[3]+1)-points[3]&&0.5*tests[1]*(tests[1]+1)-points[1]==0.5*tests[5]*(tests[5]+1)-points[5]-diff)
{
System.out.println(x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6+" are the vertices of a hexagon");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6+" are not the vertices of an acceptable figure");
}
else System.out.println(x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6+" are not the vertices of an acceptable figure");
break;
}
default:
{

switch(counter)
{
case 2:
{
System.out.println(x1+" are not the vertices of an acceptable figure");
break;
}
case 3:
{
System.out.println(x1+" "+x2+" are not the vertices of an acceptable figure");
break;
}
case 6:
{
System.out.println(x1+" "+x2+" "+x3+" "+x4+" "+x5+" are not the vertices of an acceptable figure");
break;
}

}
}
}
line = reader.readLine();
counter = 1;
}
}
}