wojiaocbj

CROR

Mar 17th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. /*
  2.  Author: 曹北健
  3.  Result: AC Submission_id: 4144645
  4.  Created at: Thu Mar 10 2022 08:39:45 GMT+0800 (China Standard Time)
  5.  Problem_id: 5407   Time: 21    Memory: 1704
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <math.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #pragma warning(disable:4996)
  14. typedef long long LL;
  15. typedef unsigned long long ULL;
  16. #define MAX(a,b) (((a)>(b))?(a):(b))
  17. #define SETBIT(gpio,bit) ((gpio)|=(1<<(bit)))
  18. #define RESETBIT(gpio,bit) ((gpio)&=~(1<<(bit)))
  19. #define READBIT(gpio,bit) (((gpio)>>(bit))&1)
  20. #define CROL(X,i,n) ((((X)<<(i))|((X)>>((n)-(i))))&((1ull<<(n))-1ull))
  21. #define CROR(X,i,n) ((((X)>>(i))|((X)<<((n)-(i))))&((1ull<<(n))-1ull))
  22. #define CROL64(X,i) (((X)<<(i))|((X)>>(64-(i))))
  23. #define CROR64(X,i) (((X)>>(i))|((X)<<(64-(i))))
  24. int main(){
  25. #ifdef _DEBUG
  26.     FILE *fp = freopen("input.txt", "r", stdin);
  27.     //FILE *fp2 = freopen("output.txt", "w", stdout);
  28. #endif // _DEBUG
  29.     LL a, b;
  30.     int n;
  31.     ULL x;
  32.     char op;
  33.     while(~scanf("%lld %lld %c %d", &a, &b, &op, &n)){
  34.         n %= 64;
  35.         x = (((ULL)((a&0xffffffffuLL) << 32)) | (ULL)(b & 0xffffffffuLL));
  36.         if(op == 'l'){
  37.             x = CROL(x, n, 64);
  38.         }
  39.         else{
  40.             x = CROR(x, n, 64);
  41.         }
  42.         printf("%d %d\n", (int)((x >> 32)), (int)(x));
  43.     }
  44. #ifdef _DEBUG
  45.     freopen("CON", "r", stdin);
  46.     //freopen("CON", "w", stdout);
  47.     system("pause");
  48. #endif // _DEBUG
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment