Advertisement
vitormartinotti

Acoes

May 14th, 2024
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int calcula(int n, int k){
  4.     if(n <= k) return 1;
  5.     int piso = n/2;
  6.     int teto = n-piso;
  7.     return calcula(piso, k) + calcula(teto, k);
  8. }
  9.  
  10. int main() {
  11.  
  12.     while(true){
  13.  
  14.         int n, k; scanf("%d %d", &n, &k);
  15.         if(n==0 && k==0) break;
  16.  
  17.         printf("%d\n", calcula(n,k));
  18.  
  19.     }
  20.  
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement