Advertisement
Spocoman

The Pyramid Of King Djoser

Sep 22nd, 2023
1,092
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int basis, size, step = 0;
  8.     cin >> basis;
  9.  
  10.     double increment;
  11.     cin >> increment;
  12.  
  13.     double stone = 0, marble = 0, lapis = 0, gold = 0;
  14.  
  15.     for (int i = basis; i > 0; i -= 2) {
  16.         size = i * i;
  17.         step++;
  18.         if (i < 3) {
  19.             gold = size * increment;
  20.         }
  21.         else {
  22.             stone += (i - 2) * (i - 2) * increment;
  23.             double decorate = (i * 4 - 4) * increment;
  24.             if (step % 5 != 0) {
  25.                 marble += decorate;
  26.             }
  27.             else {
  28.                 lapis += decorate;
  29.             }
  30.         }
  31.     }
  32.  
  33.     cout << "Stone required: " << ceil(stone) << endl
  34.         << "Marble required: " << ceil(marble) << endl
  35.         << "Lapis Lazuli required: " << ceil(lapis) << endl
  36.         << "Gold required: " << ceil(gold) << endl
  37.         << "Final pyramid height: " << floor(step * increment) << endl;
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement