#include <iostream>
using namespace std;
int Vegetables(int month)
{
int cucumbers = 0;
for (int i = 0; i < month; i++)
{
cucumbers += 5;
}
return cucumbers;
}
int decoration(int gold_amount, int gold_per_decoration)
{
int decor = 0;
while (gold_amount > 0)
{
decor++;
gold_amount -= gold_per_decoration;
}
return decor - 1;
}
int main()
{
setlocale(LC_ALL, "rus");
int month = 30, gold_amount = 3037, gold_per_decoration = 5;
cout << "В месяц, длинною в 30 дней, созревает " << Vegetables(month) << " огурцов" << endl;
cout << "Из " << gold_amount << " грамм золота, можно получить " << decoration(gold_amount, gold_per_decoration) << " украшений" << endl;
return 0;
}
#include <iostream>
typedef long long ll;
using namespace std;
bool ll_is_valid(ll t, ll N, ll x, ll y)
{
return t / x + (t - x) / y >= N;
}
ll f(ll N, ll x, ll y)
{
ll R = 1;
while (!ll_is_valid(R,N,x,y)) R *= 2;
ll L = R / 2;
while(R - L > 1)
{
ll M = (L + R) / 2;
if (!ll_is_valid(M,N,x,y)) {L = M;}
else {R = M;}
}
return R;
}
int main()
{
ll N,x,y;
cin >> N >> x >> y;
if(x > y) swap( x, y );
cout << f(N, x, y) << std::endl;
}
1)
#include <iostream>
using namespace std;
int main()
{
cout << 5 * 30 << endl;
return 0;
}
2)
#include <iostream>
using namespace std;
int main()
{
cout << 3037 / 5 << endl;
return 0;
}
Объяснение: