wojiaocbj

bitop

Apr 1st, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. /*
  2.  Author: 曹北健(37509)
  3.  Result: AC Submission_id: 4267578
  4.  Created at: Sat Apr 02 2022 11:50:25 GMT+0800 (China Standard Time)
  5.  Problem: 5455  Time: 4 Memory: 1736
  6. */
  7.  
  8. #include <stdio.h>
  9. int main(){
  10. char buffer[100] = { 0 };
  11.     scanf("%s", buffer);
  12.     int n = strlen(buffer), i;
  13.     unsigned long long ans = 0, p = 0;
  14.     for(i = n - 1; i >= 0; i--){
  15.         ans |= ((unsigned long long)(buffer[i] - '0') << (unsigned long long )p);
  16.         p++;
  17.     }
  18.     printf("%llu\n", ans);
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment