Linux和MinGW(ZOJ)上hash_set和hash_map使用方案
2011-03-19 11:13
225 查看
ZOJ2421
头文件:
#include <ext/hash_set>
#include <ext/hash_map>
命名空间:
using namespace __gnu_cxx;
/* * PKU2081.cpp * * Created on: 2011-3-19 * Author: Administrator */ #include <stdio.h> //#include <set> #include <ext/hash_set> using namespace std; using namespace __gnu_cxx; const int MAXK = 500000 + 1; //set<int> s1; hash_set<int> s1; int a[MAXK]; int main () { a[0] = 0; s1.insert(a[0]); for (int i = 1; i <= MAXK; i++) { a[i] = a[i-1] - i; if (a[i] > 0 && s1.find(a[i]) == s1.end()) ; else a[i] = a[i-1] + i; s1.insert(a[i]); } // for (int i = 0; i < 20; i++) // printf("%d: %d\n", i, a[i]); while (true) { int n; scanf("%d", &n); if (n == -1) break; printf("%d\n", a ); } return 0; }
头文件:
#include <ext/hash_set>
#include <ext/hash_map>
命名空间:
using namespace __gnu_cxx;
相关文章推荐
- Linux 下hash_map的使用
- 模拟大数据处理、linux下hash_map()使用
- 使用linux的GDB打印STL(vector,map,set..................)
- 使用HashSet<String>将map集合去重
- linux关于hash_map的使用(基于c++的,以string的key为例)
- linux hash_map的使用(g++)
- 在windows 和 linux下引入hash_set、hash_map头文件
- linux下使用hash_map及STL总结
- 在windows 和 linux下引入hash_set、hash_map头文件(转)
- Linux包括hash_map和hash_set的not declared问题
- 在windows 和 linux下引入hash_set、hash_map头文件
- 20170725使用linux的GDB打印STL(vector,map,set..................)
- linux下C++ STL hash_map的使用以及使用char *型变量作为Key值的一大“坑”
- 在windows 和 linux下引入hash_set、hash_map头文件
- linux下使用hash_map及STL总结
- Linux包含hash_map和hash_set的not declared问题
- linux hash_map的使用
- hash_set, hash_map在linux下编译出现not declared的解决方法
- linux下使用hash_map及STL总结
- Linux 下hash_map的使用