#include <cmath>
#include <iostream>
template<typename T>
T NOD(T var1, T var2)
{
while(var1 != var2)
if(var1 > var2)
var1 = var1 - var2;
else var2 = var2 - var1;
}
return var1;
int main()
int
z, x, a, d;
size_t number(0);
std::cin >> z >> a >> d;
x = z > 0 ? -3*z : pow(z, 2);
for(int i = 1; i < x; i++)
if(NOD<int>(i, x) == 1)
number++;
std::cout << 2 * number * static_cast<int>(a * sin(x) + d * exp(-(x+3))) << std::endl;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <cmath>
#include <iostream>
template<typename T>
T NOD(T var1, T var2)
{
while(var1 != var2)
{
if(var1 > var2)
var1 = var1 - var2;
else var2 = var2 - var1;
}
return var1;
}
int main()
{
int
z, x, a, d;
size_t number(0);
std::cin >> z >> a >> d;
x = z > 0 ? -3*z : pow(z, 2);
for(int i = 1; i < x; i++)
{
if(NOD<int>(i, x) == 1)
number++;
}
std::cout << 2 * number * static_cast<int>(a * sin(x) + d * exp(-(x+3))) << std::endl;
}