Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- int calcula(int n, int k){
- if(n <= k) return 1;
- int piso = n/2;
- int teto = n-piso;
- return calcula(piso, k) + calcula(teto, k);
- }
- int main() {
- while(true){
- int n, k; scanf("%d %d", &n, &k);
- if(n==0 && k==0) break;
- printf("%d\n", calcula(n,k));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement