Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <iostream>
- //#include <vector>
- //#include <map>
- //#include <cinttypes>
- //typedef enum {
- // PlusZero = 0x00,
- // MinusZero = 0x01,
- // PlusInf = 0xF0,
- // MinusInf = 0xF1,
- // PlusRegular = 0x10,
- // MinusRegular = 0x11,
- // PlusDenormal = 0x20,
- // MinusDenormal = 0x21,
- // SignalingNaN = 0x30,
- // QuietNaN = 0x31
- //} float_class_t;
- //
- //typedef union {
- // double f;
- // struct {
- // uint64_t mantissa : 52;
- // uint64_t exponent : 11;
- // uint64_t sign : 1;
- // } parts;
- //} double_cast;
- //
- //extern float_class_t
- //classify(double *value_ptr) {
- // double_cast cast_ = {.f = *value_ptr};
- // uint64_t sign = cast_.parts.sign;
- // uint64_t exponent = cast_.parts.exponent;
- // uint64_t mantissa = cast_.parts.mantissa;
- //
- // std::cout << sign << ' ' << exponent << ' ' << mantissa << '\n';
- //
- // if (sign == 0 && exponent == 0 && mantissa == 0) {
- // return PlusZero;
- // }
- //
- // if (sign == 1 && exponent == 0 && mantissa == 0) {
- // return MinusZero;
- // }
- //
- // if (sign == 0 && exponent == 0x7ff && mantissa == 0) {
- // return PlusInf;
- // }
- //
- // if (sign == 1 && exponent == 0x7ff && mantissa == 0) {
- // return MinusInf;
- // }
- //
- // if (sign == 0 && exponent == 0x7ff && mantissa == 0x1) {
- // return SignalingNaN;
- // }
- //
- // if (sign == 0 && exponent == 0x7ff && mantissa == 0x2) {
- // return QuietNaN;
- // }
- //}
- #include <stdio.h>
- #include <stdint.h>
- #include <ctype.h>
- int char_to_int(char letter) {
- if (letter >= '0' && letter <= '9') {
- return (int) letter - 48;
- }
- if (letter >= 'A' && letter <= 'Z') {
- return (int) letter - 55;
- }
- if (letter >= 'a' && letter <= 'z') {
- return (int) letter - 61;
- }
- return -1;
- }
- char int_to_char(int index) {
- if (index >= 0 && index <= 9) {
- return (char) (48 + index);
- }
- index -= 10;
- if (index >= 0 && index < 26) {
- return (char) (65 + index);
- }
- index -= 26;
- return (char) (97 + index);
- }
- void print_answer(uint64_t arr) {
- for (int i = 0; i < 62; ++i) {
- if (arr & ((uint64_t) 1 << i)) {
- fputc(int_to_char(i), stdout);
- }
- }
- fputc('\n', stdout);
- }
- int main() {
- uint64_t initial = 0;
- uint64_t current = 0;
- for (;;) {
- int c = fgetc(stdin);
- if (c == EOF) {
- break;
- }
- if ((char) c == '&') {
- initial &= current;
- current = 0;
- }
- if ((char) c == '|') {
- initial |= current;
- current = 0;
- }
- if ((char) c == '^') {
- initial ^= current;
- current = 0;
- }
- if ((char) c == '~') {
- uint64_t universe = (((uint64_t) 1 << 62) - 1);
- initial = universe ^ initial;
- }
- if (isalpha(c) || isdigit(c)) {
- current |= ((uint64_t) 1 << char_to_int((char) c));
- }
- }
- print_answer(initial);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement