fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. // int n;
  6. // scanf("%d\n", &n);
  7. // for(int i = 0; i < n; i++) {
  8. // for(int j = i; j > 0; j--) {
  9. // printf("%d ", j + 1);
  10. // }
  11. // for(int j = 0; j < n - i; j++) {
  12. // printf("%d ", j + 1);
  13. // }
  14. // printf("\n");
  15. // }
  16. int a, b;
  17. scanf("%d %d\n", &a, &b);
  18.  
  19. int ans = 0;
  20. while(a >= 1) {
  21. if(a & 1) {
  22. ans += b;
  23. }
  24.  
  25. a /= 2;
  26. b *= 2;
  27. }
  28. printf("%d\n", ans);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5460KB
stdin
6 8
stdout
48