Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- enum {
- CONST127 = 0b01111111,
- CONST31 = 0b00011111,
- CONST15 = 0b00001111,
- CONST7 = 0b00000111,
- CONST6 = 0b110,
- CONST14 = 0b1110,
- CONST63 = 0b00111111,
- CONST5 = 0b101,
- CONST4 = 0b100,
- BORDER1 = 0x0400,
- BORDER2 = 0x04FF
- };
- int main() {
- int cnt = 0;
- int kircnt = 0;
- int s = getchar();
- int cur = 0;
- int flag = 0;
- while (s != EOF) {
- if (flag == 0) {
- if (BORDER1 <= cur && cur <= BORDER2) {
- ++kircnt;
- }
- ++cnt;
- if ((s >> CONST7) == 0) {
- cur = s & CONST127;
- flag = 1;
- } else if ((s >> CONST5) == CONST6) {
- cur = s & CONST31;
- flag = 2;
- } else if ((s >> CONST4) == CONST14) {
- cur = s & CONST15;
- flag = 3;
- } else {
- cur = s & CONST7;
- flag = 4;
- }
- } else {
- s = s & CONST63;
- cur = (cur << CONST6) + s;
- }
- --flag;
- s = getchar();
- }
- if (BORDER1 <= cur && cur <= BORDER2) {
- ++kircnt;
- }
- printf("%d %d\n", cnt, kircnt);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement