|
|
back to boardWA 2 Posted by DejaVu 5 Oct 2019 23:01 #include <iostream> using namespace std; int main() { long int n, k; cin >> n >> k; long int a = 1; long int h = 0; if(n == 1){ cout << 0; } else if(n == 2){ cout << 1; } else{ while(n != 0){ if(a > k && a < n){ a = k; n -= a; h++; } else if(a > n){ n = 0; h++; } else{ n -= a; a *= 2; if(a > k){ a = k; } h++; } } cout << h; } } |
|
|