Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int basis = Integer.parseInt(scanner.nextLine()),
- size, step = 0;
- double increment = Double.parseDouble(scanner.nextLine()),
- stone = 0, marble = 0, lapis = 0, gold = 0;
- for (int i = basis; i > 0; i -= 2) {
- size = i * i;
- step++;
- if (i < 3) {
- gold = size * increment;
- } else {
- stone += (i - 2) * (i - 2) * increment;
- double decorate = (i * 4 - 4) * increment;
- if (step % 5 != 0) {
- marble += decorate;
- } else {
- lapis += decorate;
- }
- }
- }
- System.out.printf(
- """
- Stone required: %d
- Marble required: %d
- Lapis Lazuli required: %d
- Gold required: %d
- Final pyramid height: %d
- """
- , (int) Math.ceil(stone),
- (int) Math.ceil(marble),
- (int) Math.ceil(lapis),
- (int) Math.ceil(gold),
- (int) (step * increment)
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement