kalina19762005
04.03.2022 11:36

Mech's spaceship landed on an alien planet. The brave explorer decided to have a walk around. The scenery was very picturesque - huge rocks under the black sky with several moons... Soon he approached an edge of a terrifying hole. He looked down and suddenly saw there one of the planet's moons - the hole went down through the whole planet!! "Abyss..." - Mech whispered in primal awe. He was so impressed that decided to estimate how large the abyss is in comparison with the planet. To start with he wants to calculate the actual volume of the planet i.e. its volume without the space in the abyss. Assume that the planet is a perfect ball and the abyss has the form of a cylinder that is symmetrically cut out of the ball as shown below. The only information Mech managed to get is the depth of the abyss. He now wonders if it is possible to calculate the volume of the ball with the cut out cylinder of the given depth. Help him and write a program to calculate it without knowing the radius of the planet. Don't be surprised - it is really possible!

Hint: consider the previous sentence as a hint :))

Input

Input will contain only one real number 0<=depth<=100 - the depth of the abyss in megameters.

Output

Your program should produce only one line with the actual volume of the planet in cubic megameters rounded to three digits after decimal point.

Sample input

0.31

Sample output
0.016

cрочно

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Kirka3118
06.06.2023 19:41

Объяснение:

В общем алгоритм такой.

Пусть мы имеем массив a[1..n, 1..n] из n*n элементов,

i - номер строки, j - номер столбца.

Спускаемся вниз по строкам до строки, номер которой отличается от того,

n - четное или нечетное.

В общем случае это номер i_ser, равный n делить на 2, и округленный до целого вниз.

Например, если n = 4, i_ser = 2, если n = 7, то i_ser = 3.

Для i от 1 до i_ser делать

 начало

   Для j от 1 до i делать

     // здесь мы получаем нужные нам координаты i, j

 конец

Если i_ser нечетно, то отдельно проходимся по строке с номером i_ser+1

Если i_ser нечетно то

 начало

   i_ser = i_ser + 1

Для j от 1 до i_ser делать

     // здесь мы получаем нужные нам координаты i_ser, j

 конец

 

i_ser = i_ser + 1      

Для i от i_ser до n делать

 начало

   Для j от 1 до n - i + 1 делать

     // здесь мы получаем нужные нам координаты i, j

 конец

0,0(0 оценок)
Ответ:
Kata8i77866
01.03.2020 07:43
1)
#include<iostream>
#include<cmath>  
void main() {    
char ch1, ch2;    
int vol1, vol2;          
std::cin >> ch1 >> vol1;        
std::cin >> ch2 >> vol2;                            
if abs(ch1 - ch2) <= 2) && (abs(vol1 - vol2) <= 2)) && ((ch1 != ch2) && (vol1 != vol2))) && !((abs(ch1 - ch2)==1) && (abs(vol1-vol2))==1))             std::cout << "Possible";                    
else            
std::cout << "Impossible";        
}
3)
#include<iostream> 
using namespace std; 
void main() {    
int n,m;
cin >> n,m;
cout<<n;
for(int i=n;i<=m;i++)
cout<<i+2;
}
4)

#include <iostream>
using namespace std; void main(){
int mass[2][4]   //размерность своего массива вписывай.
{
{ 1, 2, 3, 4 },  //вписывай свои числа.
{ 1, 2, 3, 4 }  
};

for (int i=0 ; i<2;++i)
{
for (int j=0 ; j<4;++j)
{
if(mass[i][j]<0)
 cout<<mass[i][j];
}
}
system("pause");
}

 
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота