Theatre Square

描述:

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 surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.

输入:

The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

输出:

Write the needed number of flagstones.

描述:

在伯兰首都的剧院广场是一个尺寸为 n x m 米的矩形的形状。在这座城市的周年纪念日这个特殊的时刻,做出了一个用正方形的花岗岩石板去铺广场的决定。每一块石板的尺寸都是 a x a 。

问最少需要多少块石板去铺广场?允许覆盖比剧院广场更大的表面,但广场必须被覆盖。不允许打破石板。石板的边沿应与广场的边沿平行。

输入:

第一行输入包括三个正整数:n, m, a (1 ≤  n, m, a ≤ 109)

输出:

编写程序输出需要的石板数量。

题目地址链接:Problem - A - Codeforces

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, here is an example implementation in Java: ```java import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; public class Student { private String name; private ArrayList<String> hobbies; public Student(String name, ArrayList<String> hobbies) { this.name = name; this.hobbies = hobbies; } public String getName() { return name; } public ArrayList<String> getHobbies() { return hobbies; } public static void main(String[] args) { ArrayList<Student> students = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader("students.txt"))) { String line; while ((line = br.readLine()) != null) { String[] parts = line.split(","); String name = parts[0]; ArrayList<String> hobbies = new ArrayList<>(); for (int i = 1; i < parts.length; i++) { hobbies.add(parts[i]); } students.add(new Student(name, hobbies)); } } catch (IOException e) { System.err.format("IOException: %s%n", e); } Collections.sort(students, (s1, s2) -> s1.getName().compareTo(s2.getName())); for (Student student : students) { System.out.println(student.getName() + ": " + student.getHobbies()); } } } ``` This code reads the student data from a file called "students.txt" (in the same directory as the Java file), creates a `Student` object for each line, and stores them in an `ArrayList`. It then sorts the list by student name using a lambda expression, and finally prints out each student's name and hobbies using a `for` loop.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值