Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int cnt = 0;
- int kircnt = 0;
- int s = getchar();
- int cur = 0;
- int flag = 0;
- while (s != 'X') {
- if (flag == 0) {
- if (0x0400 <= cur && cur <= 0x04FF) {
- ++kircnt;
- }
- ++cnt;
- if ((s >> 7) == 0) {
- cur = s & 0b01111111;
- flag = 1;
- } else if ((s >> 5) == 0b110) {
- cur = s & 0b00011111;
- flag = 2;
- } else if ((s >> 4) == 0b1110) {
- cur = s & 0b00001111;
- flag = 3;
- } else {
- cur = s & 0b00000111;
- flag = 4;
- }
- } else {
- cur = (cur << 8) + s;
- }
- --flag;
- s = getchar();
- }
- printf("%d %d", cnt, kircnt);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement