Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cl.exe /EHsc /Ox hash.cpp
- #include <iostream>
- #include <string>
- #include <unordered_map>
- #include <stdlib.h>
- using namespace std;
- int main(int argc, char *argv[])
- {
- int n = ((argc == 2) ? atoi(argv[1]) : 1);
- unordered_map<string, int> X;
- char hexString[20];
- for (int i=1; i<=n; i++) {
- itoa(i, hexString, 16);
- X[ strdup(hexString) ] = i;
- }
- int c = 0;
- for (int i=n; i>0; i--) {
- if (X.find(to_string(i)) != X.end()) c++;
- }
- cout << c << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement