Advertisement
pasholnahuy

Untitled

Nov 19th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int cnt = 0;
  5. int kircnt = 0;
  6. int s = getchar();
  7. int cur = 0;
  8. int flag = 0;
  9. while (s != 'X') {
  10. if (flag == 0) {
  11. if (0x0400 <= cur && cur <= 0x04FF) {
  12. ++kircnt;
  13. }
  14. ++cnt;
  15. if ((s >> 7) == 0) {
  16. cur = s & 0b01111111;
  17. flag = 1;
  18. } else if ((s >> 5) == 0b110) {
  19. cur = s & 0b00011111;
  20. flag = 2;
  21. } else if ((s >> 4) == 0b1110) {
  22. cur = s & 0b00001111;
  23. flag = 3;
  24. } else {
  25. cur = s & 0b00000111;
  26. flag = 4;
  27. }
  28.  
  29. } else {
  30. cur = (cur << 8) + s;
  31. }
  32. --flag;
  33. s = getchar();
  34. }
  35. printf("%d %d", cnt, kircnt);
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement