ACM/ICPC笔记

一:数据类型和取值范围
1) 64bit 位数据的类型,输入,输出
 带符号的(long long):
 数据范围:-9223372036854775808(19位>-1*10^19) - +9223372036854775807(19位<1*10^19)
 typename: long long x;
 input:  scanf("%I64d", &x);
 output:  printf("%I64d", x);

 无符号(unsigned long long):
 只要用之前加上unsigned 和 改成%I64u就行,数据范围:0 - +18446744073709551615(20位<2*10^19)

2) 32bit带符号数据范围:-2147483648(10位>-3*10^9) - +2147483647(10位<3*10^9)
 32bit无符号数据范围:0 - +4294967295(10位<5*10^9)

 
 
二: C++ STL容器 和 Java Collection集合-接口
1) #include <vector> Java: ArrayList-List // 向量
 #include <list>  Java: LinkedList-List // 双向链表
 #include <deque> Java: LinkedList-Deque // 双向队列
 #include <set>  Java: TreeSet-Set  // 集合,内部有序
 C++中分为:set是无重复集,multiset是由重复集
 #include <map>  Java: TreeMap-Map  // 映射,内部有序
 C++中分为:map和multimap区别同上
 #include <queue>
  queue   Java: LinkedList-Queue
  priority_queue Java: PriorityQueue-Queue
 #include <stack> Java: Stack-Stack  // stack:LIFO队列,堆栈
 using namespace std; Java: import java.util.*;
 其中Java的Vector,Stack是线程同步的,效率相对较差
 
2)
 还有两个是STL扩展容器:hash_map和hash_set,哈希表实现
 与map,set类似,但是内部实现不同,

 如果想使用hash_map和hash_set,由于其不是STL容器,故采用以下写法(GCC/G++编译器)
 #include <ext/hash_map>  Java: HashMap-Map // 大数据量频繁查询,修改
 #include <ext/hash_set>  Java: HashSet-Set // 大数据量频繁查询

 using namespace __gnu_cxx; Java: import java.util.*
 using namespace std;
 
 其中Java的Hashtable,Properties是线程同步的,效率相对较差
Collection
........|--------List
........|..........|----------ArrayList
........|..........|----------Vector
........|..........|.............|-----Stack
........|..........|----------LinkedList
........|--------Set
...................|----------HashSet.
...................|.............|-----LinkedHashSet
...................|----------SortedSet
.................................|-----TreeSet
 
Iterator
.....|-------ListIterator
 
Map
.....|------Hashtable
.....|..........|------Properties
.....|------HashMap
.....|..........|------LinkedHashMap
.....|------WeakHashMap
.....|------SortedMap
................|------TreeMap

详见Java util之常用数据类型特性盘点

原文地址:https://www.cnblogs.com/nysanier/p/1988889.html