SHARE
TWEET

Untitled

a guest Nov 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long Crc32(char *buf, int len)
  5. {
  6.     long long crc_table[256];
  7.     long long crc;
  8.     long long i, j;
  9.  
  10.     for (i = 0; i < 256; i++)
  11.     {
  12.         crc = i;
  13.         for (j = 0; j < 8; j++)
  14.             crc = crc & 1 ? (crc >> 1) ^ 0xEDB88320UL : crc >> 1;
  15.  
  16.         crc_table[i] = crc;
  17.     };
  18.  
  19.     crc = 0xFFFFFFFFUL;
  20.  
  21.     while (len--)
  22.         crc = crc_table[(crc ^ *buf++) & 0xFF] ^ (crc >> 8);
  23.  
  24.     return crc ^ 0xFFFFFFFFUL;
  25. }
  26.  
  27. int main()
  28. {
  29.         int flag = 1;
  30.         while(flag) {
  31.             char m[100005] = {' '};
  32.             int ch, len = 0;
  33.             while ((ch = getchar()) != '\n' && ch != ' ') {
  34.                 if(ch == EOF) {
  35.                     flag = 0;
  36.                     break;
  37.                 }
  38.                 else {
  39.                     m[len] = ch;
  40.                     len++;
  41.                 }
  42.             }
  43.  
  44.             long long ans = Crc32(m, len);
  45.             cout << ans << endl;
  46.         }
  47.  
  48.     return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top