UVA 11044 – Searching for Nessy

I failed by misreading the problem on this one. I thought the sonar beam grid was of size 4 instead of size 3. It cost me two WA’s :(

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 
 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
 * 
 */
public class P11044 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    int N = Integer.parseInt(sc.nextLine());
    while (N > 0) {
      int X = sc.nextInt();
      int Y = sc.nextInt();
      out.println((long) (Math.ceil((X - 2) * 1.0 / 3) * Math.ceil((Y - 2) * 1.0 / 3)));
      N--;
    }
    out.close();
    sc.close();
  }

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.