摘要:
例:输出从1,2......m,中任取k个数的所有组合。m=5,k=3时有543,542,541,532,531,521,432,431,421,321有C(m,k)个。法一:枚举方法 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 int main() 5 { 6 int n; 7 cin >> n; 8 for (int x = 1; x <= n - 2; ++x) 9 for (int y = x + 1; y <= n - 1; ++y)10 ... 阅读全文
posted @ 2013-03-23 23:44
PegasusWang
阅读(3153)
评论(0)
推荐(0)
摘要:
1 #include<iostream> 2 #include<string> 3 #include<iomanip> 4 #include<algorithm> 5 using namespace std; 6 7 #define MAXN 9999 8 #define MAXSIZE 10 9 #define DLEN 4 10 11 class BigNum 12 { 13 private: 14 int a[500]; //可以控制大数的位数 15 int len; //大数长度 16 public: 17 ... 阅读全文
posted @ 2013-03-23 20:05
PegasusWang
阅读(10202)
评论(2)
推荐(2)
摘要:
最近做的ural的题目总是各种错,看了解题报告都是自己没学过的玩意,有点受打击,不过ural的题目质量还是挺好的,多被虐虐有益健康。这一题要是用数组直接超内存,用优先级队列做,刚接触这个,学习一下优先级队列。c++stl头文件声明<queue>, <queue>包括queue和priority_queue, priority_queue就是优先级队列。默认使用vector容器实现。优先级队列容器总是把优先级最高的元素放在队列最前方来保持队列的有序性。假如一次push 1,2,3,4,5,6,则优先级队列中存储的是6,5,4,3,2,1。priority_queue支持的 阅读全文
posted @ 2013-03-23 19:52
PegasusWang
阅读(821)
评论(0)
推荐(0)
浙公网安备 33010602011771号