Funny you should post this thread, because I'm about to go into a programming competition on Saturday  .
So basically, we have a lot of practice problems for the competition. One of the problems in the packet is to find the smallest perimeter and area of points contained on a plane. It was rather easy.
Java:
PHP Code:
import java.util.Scanner;
public class C { public static void main(String[] args) { Scanner s = new Scanner(System.in); int caseNum = s.nextInt();
for(int i = 0; i < caseNum; i++) { //Ant farm 1 int ants = s.nextInt();
double xO = s.nextDouble(); double yO = s.nextDouble(); double lowx = xO; double lowy = yO; double highx = xO; double highy = yO;
for(int ii = 0; ii < ants - 1; ii++) { double x = s.nextDouble(); double y = s.nextDouble();
if(x < lowx) lowx = x; else if(x > highx) highx = x; if(y < lowy) lowy = y; else if(y > highy) highy = y; }
double length = highx - lowx; double width = highy - lowy; double perim = (2 * length) + (2 * width); double area = length * width; int c = i + 1; System.out.println("Case " + c + ": Area " + area + ", Perimeter " + perim); } } }
|
You doing the IEEE or ACM competition?