Построить блок схему по коду. #include
using namespace std;
int main()
{
double s, s1, s2, s3;
cout << "1 tg (KZT) = 0.18 RUB" << "\n";
cout << "1 tg (KZT) = 0.0019 EUR" << "\n";
cout << "1 tg (KZT) = 0.0023 USD" << "\n";
cout << "Vvedity summu:", cin >> s, cout << "\n";
s1 = s*0.18;
s2 = s*0.0019;
s3 = s*0.0023;
cout << s << " tenge (KZT) = " << s1 << " RUB, " << s2 << " EUR, " << s3 << " USD" << "\n";
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;
}
def zadanie(line, time)
line = line.gsub(/[^MD]/, "")
time.times { |i|
k = 0
while k < line.size - 1 do
if line[k..k + 1] == "MD"
line[k], line[k + 1] = line[k + 1], line[k]
k+=1
end
k+=1
end
p [i+1,line]
}
return line
end
# # Примеры применения
p zadanie("MDDDMMDMDDDDDM", 10)
# p zadanie("MMDMMMDDDMDDDMD", 10)
# p zadanie("MMMDMM", 5)
Вывод
[1, "DMDDMDMDMDDDMDM"]
[2, "DDMDDMDMDMDDMDMM"]
[3, "DDDMDDMDMDDMDMMM"]
[4, "MDDMDDMD"]
[5, "MDDDMD"]
[6, "MDMMMDMD"]
[7, "MMMDMD"]
[8, "MMDMD"]
[9, "MDMD"]
[10, "MD"]
"MD"