#include "stdio.h" #include "stdlib.h" #include "vector" using namespace std; int minimum(int c1, int c2) { return (c1 p1; while (c1 != 1) { p1.push_back(c1); if (c1%2 == 0) { c1 /= 2; } else { c1 = 3*c1+1; } } p1.push_back(c1); vector p2; while (c2 != 1) { p2.push_back(c2); if (c2%2 == 0) { c2 /= 2; } else { c2 = 3*c2+1; } } p2.push_back(c2); int rozdil = abs(p1.size()-p2.size()); int prvni = p1.size(); int druhy = p2.size(); if (p1.size() > p2.size()) { for (unsigned int i=0; i p2.size()) printf("%d needs %d steps, %d needs %d steps, they meet at %d\n",sc1,prvni,sc2,druhy,p1[rozdil+minimum(prvni,druhy)]); else printf("%d needs %d steps, %d needs %d steps, they meet at %d\n",sc1,prvni,sc2,druhy,p2[rozdil+minimum(prvni,druhy)]); scanf("%d%d",&c1,&c2); } return 0; }