Advertisement
pasholnahuy

Untitled

Nov 20th, 2023
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. enum {
  4. CONST127 = 0b01111111,
  5. CONST31 = 0b00011111,
  6. CONST15 = 0b00001111,
  7. CONST7 = 0b00000111,
  8. CONST6 = 0b110,
  9. CONST14 = 0b1110,
  10. CONST63 = 0b00111111,
  11. CONST5 = 0b101,
  12. CONST4 = 0b100,
  13. BORDER1 = 0x0400,
  14. BORDER2 = 0x04FF
  15. };
  16.  
  17. int main() {
  18. int cnt = 0;
  19. int kircnt = 0;
  20. int s = getchar();
  21. int cur = 0;
  22. int flag = 0;
  23. while (s != EOF) {
  24. if (flag == 0) {
  25. if (BORDER1 <= cur && cur <= BORDER2) {
  26. ++kircnt;
  27. }
  28. ++cnt;
  29. if ((s >> CONST7) == 0) {
  30. cur = s & CONST127;
  31. flag = 1;
  32. } else if ((s >> CONST5) == CONST6) {
  33. cur = s & CONST31;
  34. flag = 2;
  35. } else if ((s >> CONST4) == CONST14) {
  36. cur = s & CONST15;
  37. flag = 3;
  38. } else {
  39. cur = s & CONST7;
  40. flag = 4;
  41. }
  42.  
  43. } else {
  44. s = s & CONST63;
  45. cur = (cur << CONST6) + s;
  46. }
  47. --flag;
  48. s = getchar();
  49. }
  50. if (BORDER1 <= cur && cur <= BORDER2) {
  51. ++kircnt;
  52. }
  53. printf("%d %d\n", cnt, kircnt);
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement