Skip to content

Instantly share code, notes, and snippets.

@gauravvichare
Created April 14, 2013 14:41
Show Gist options
  • Save gauravvichare/5382975 to your computer and use it in GitHub Desktop.
Save gauravvichare/5382975 to your computer and use it in GitHub Desktop.
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surfa…
import java.util.Scanner;
public class theatre {
public static void main(String[] args) {
double n,m,a;
Scanner in = new Scanner(System.in);
n = in.nextDouble(); // accept width of theatre square
m = in.nextDouble(); //accept length of theatre square
a = in.nextDouble(); //accept side of flagstone
System.out.println((long)Math.ceil(n/a)*(long)Math.ceil(m/a) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment