Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <string>
- #include <math.h>
- #include <vector>
- using namespace std;
- int sqrtfind(int n, int t)
- {
- int prom;
- prom = n;
- while (prom !=1)
- {
- prom = prom / 2;
- t++;
- }
- return t;
- }
- void powfind(long long k, long long n, long long prom, long long i)
- {
- while (prom < n)
- if (prom <= k)
- {
- prom = prom * 2;
- i++;
- }
- else
- {
- if (((n - prom) % k) * 10 != 0)
- {
- cout << i + (n - prom) / k + 1;
- return;
- }
- else
- {
- cout << i + (n - prom) / k;
- return;
- }
- }
- cout << i;
- }
- int main()
- {
- long long n, k, hours = 0;
- cin >> n >> k;
- if (n <= k)
- if (n % 2 * 10 != 0)
- cout << sqrtfind(n, 0) + 1;
- else
- cout << sqrtfind(n, 0);
- else
- {
- powfind(k, n, 1, 0);
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement