#include <iostream>
#include <ctime>
int main() {
std::cout<<"n = ";
unsigned int n;
std::cin >> n;
{
std::cout<<"Спосіб 1\n";
std::clock_t t = std::clock();
double total_product = 1.;
for(int i=1; i<=n; ++i)
{
double product = 1.;
for(int j=1; j<=i; ++j)
product *= (1.+1./i);
total_product *= product;
}
double mks = 1e6*(std::clock()-t)/CLOCKS_PER_SEC;
std::cout<<"Результат: "<<total_product<<'\n';
std::cout<<"Час: "<<mks<<"mks\n";
}
{
std::cout<<"Спосіб 2\n";
std::clock_t t = std::clock();
double product = 1.;
for(int i=1; i<=n; ++i)
for(int j=1; j<=i; ++j)
product *= (1.+1./i);
double mks = 1e6*(std::clock()-t)/CLOCKS_PER_SEC;
std::cout<<"Результат: "<<product<<'\n';
std::cout<<"Час: "<<mks<<"mks\n";
}
{
std::cout<<"Спосіб 3\n";
std::clock_t t = std::clock();
double product = 1., current = 1.;
for(int i=n;i>0;--i)
{
current *= (1.+1./i);
product *= current;
}
double mks = 1e6*(std::clock()-t)/CLOCKS_PER_SEC;
std::cout<<"Результат: "<<product<<'\n';
std::cout<<"Час: "<<mks<<"mks\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3RpbWU+CgppbnQgbWFpbigpIHsKCXN0ZDo6Y291dDw8Im4gPSAiOwoJdW5zaWduZWQgaW50IG47CglzdGQ6OmNpbiA+PiBuOwoJewoJCXN0ZDo6Y291dDw8ItCh0L/QvtGB0ZbQsSAxXG4iOwoJCXN0ZDo6Y2xvY2tfdCB0ID0gc3RkOjpjbG9jaygpOwoJCWRvdWJsZSB0b3RhbF9wcm9kdWN0ID0gMS47CgkJZm9yKGludCBpPTE7IGk8PW47ICsraSkKCQl7CgkJICAgIGRvdWJsZSBwcm9kdWN0ID0gMS47CgkJICAgIGZvcihpbnQgaj0xOyBqPD1pOyArK2opCgkJICAgICAgICBwcm9kdWN0ICo9ICgxLisxLi9pKTsKCQkgICAgdG90YWxfcHJvZHVjdCAqPS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