
C++应用
文章平均质量分 61
lazy_virus
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj3481——Double Queue
map应用!map网上详细讲解地址:http://www.kuqin.com/cpluspluslib/20071231/3265.htmlhttp://mxdxm.javaeye.com/blog/518571http://weihuachao1984.blog.163.com/blog/static/328712862008102411386264/#pragma warning (disable:4786) #include #include #include using namespace原创 2010-10-14 17:14:00 · 605 阅读 · 0 评论 -
poj1716——Integer Intervals//差分约束系统
对于差分约束系统,注意:1,加入源点,保证其他每个顶点到源点可达(对于此题,可以不加);2,要找出题目中所有隐含关系;3,>=、#include #include #include #include #include #include #include #inclu原创 2011-07-18 18:37:22 · 449 阅读 · 0 评论 -
poj1325——Machine Schedule//最小顶点覆盖
题意:一项工作,可由A机器的mode_a完成,或者由B机器的mode_b完成,现在要完成K项这样的工作,而每次转换一次mode,需要重启一次机器。问,最少需重启多少次? 思路:要尽量让参与的mode_x数尽可能少。转化为最小顶点覆盖:即让每项工作的mode_a、mode_b之间原创 2011-08-09 21:31:07 · 447 阅读 · 0 评论 -
qsort应用!
七种qsort排序方法 一、对int类型数组排序 int num[100]; Sample: int cmp ( const void *a , const void *b ) { return *(int *)a - *(int *)b; } qsort(num转载 2011-03-05 20:08:00 · 446 阅读 · 0 评论 -
ZOJ 3490 String Successor//字符串处理
原来,原来,这句漏掉了“the left of the leftmost alphanumeric” (z)的后继是(aa) o(╯□╰)o 细心很重要。 #include #include #include using namespace std; bool alph(char str[]) { int len=strlen(str),i; for(i=0;i<len;i++原创 2012-02-01 19:29:26 · 1216 阅读 · 0 评论 -
hdu1717 小数化分数2
参照:http://www.cnblogs.com/Yu2012/archive/2011/09/22/2184764.html #include #include #include #include using namespace std; int gcd(int a,int b) { int temp=0; while(b!=0) { temp=a%b; a原创 2012-02-24 19:33:08 · 495 阅读 · 0 评论 -
中山大学 1238: 兵临城下//优先队列
维护两队列。 #include #include #include using namespace std; class node1 { public : int time,pth; }; bool operator< (const node1 &a,const node1 &b) { return a.pth >b.pth ; } class node2 { public : int t原创 2012-02-17 16:48:56 · 513 阅读 · 0 评论 -
zoj 3574 Under Attack II//归并排序
求逆序对。其实,就是求交点。利用了归并排序的稳定性。 #include #include #include using namespace std; class node { public: int ly,ry; int num; }; node date[30005],temp[30005]; int ans=0; int cmp(const void *a,const void *b)原创 2012-02-28 19:31:49 · 704 阅读 · 0 评论 -
zoj2833 Friendship //并查集
简单并查集。ps:输出超恶心,用队列搞... #include #include #include #include using namespace std; #define N 100005 int n,m; int rank[N],father[N]; class node { public: queueq; int num; }; node p[100]; void set(int原创 2012-03-06 22:37:07 · 684 阅读 · 0 评论 -
zoj 3230Solving the Problems//优先队列
#include #include #include #include #include using namespace std; #define N 100005 class node { public: int a,b; }; bool operator< (const node &a,const node &b) { if(a.b<b.b ) return true; return f原创 2012-03-10 20:21:08 · 553 阅读 · 0 评论 -
hdu1466 计算直线的交点数//dp+set
#include #include #include using namespace std; class node { public: sett; }; node st[21]; int main() { st[1].t .insert (0); st[2].t .insert (0); st[2].t .insert (1); st[3].t .insert (0); st[3].原创 2012-03-17 20:25:08 · 727 阅读 · 0 评论 -
wxWidgets之clipboard参照于sample.
#include "wx/wxprec.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "HelloWorldApp.h" #include #include "wx/clipbrd.h" enum { ID_Quit = wxID_EXIT, ID_About = wxID_ABOUT,原创 2013-09-11 21:35:34 · 892 阅读 · 0 评论 -
疑惑代码
#include #include using namespace std; class Triangular { public: Triangular(){_length=1;_beg_pos=1;_next=0;} Triangular(int len,int beg_pos){_length=len; _beg_pos=beg_pos;} int length()const {re原创 2013-10-17 15:20:59 · 618 阅读 · 0 评论 -
poj3715——Blue and Red//最小顶点覆盖
看题的时候,看不出这是最小顶点覆盖,悲剧。注意点:1,顶点从0开始,所以,my[]的标记不能以0为标准。 2,枚举法确实很不错。#include #include using namespace std; int n,m; int f[220]; c原创 2011-07-12 12:10:27 · 723 阅读 · 0 评论 -
poj3720——Occurrence of Digits//循环节
#include using namespace std; #define esp 1e-10 int ans[102][11]; int vis[1000]; void getans(int n) { int now=10; memset(vis,0,sizeof(vis)原创 2011-07-10 19:46:11 · 741 阅读 · 0 评论 -
复习笔记
考完了c++,上传一点笔记,以便寒假的时候,继续复习!1. #include using namespace std; //静态成员的初始化,虽然有可能成为全局变量,但因为是static,所以仍是安全的 //int x=100; //class Ws //{ // static int x; // static int y; //public : // void print () const // { // cout class Array { en原创 2010-12-23 17:22:00 · 424 阅读 · 0 评论 -
poj1724——ROADS
建图很巧妙,必须掌握了,不需指针!对比赛很实用!#include #include struct node { int v,dis,cost,next; }edge[10005]; int head[105]; bool vis[105]; int n,k,m,len,ans; void add(int a,int b,int c,int d) { edge[++len].v=b; edge[len].cost =d; edge[len].dis =c; edge[le原创 2010-11-02 09:13:00 · 651 阅读 · 0 评论 -
字符转换与文件为空的判断
<br />String与string的转化 String转化为std::string 例子: CString strMfc="test"; std::string strStl; strStl=strMfc.GetBuffer(0); std::string转化为CString 例子: CString strMfc; std::string strStl="test"; strMfc=strStl.c_str(); 文件为空的判断方法 ofstream App("fp.tx原创 2011-01-14 15:31:00 · 546 阅读 · 0 评论 -
关于类及构造函数!
<br />Complex.h<br /> // complex.h #ifndef COMPLEX_H #define COMPLEX_H class Complex { public: double realPart; double imaginaryPart; Complex( double real, double imaginary ); void Complex::addition( const Complex &a ); void Complex::su原创 2010-11-21 14:40:00 · 532 阅读 · 0 评论 -
priority_queue的用法!
#include #include using namespace std; /*///////////////////////////////////////////////////////////// less 这是按值大的优先 greater这是按值小的优先 int main() { priority_queuett;//默认情况下,较大值有较高的优先权 for(int i=0;i tt.push (rand()%10); while(原创 2011-03-13 20:56:00 · 372 阅读 · 0 评论 -
poj1442——Black Box
<br />题目很难理解:向一个容器中不断的添加n个数,然后有一系列查询,每次查询第i小的数并进行输出.<br />刚开始就一个最小堆,果断超时了。<br />后来,搜了报告,原来,是用最大与最小堆之间动态维护。保证前i小个数一定留在max堆里。<br />话说,stl是好东西,代码简洁。但比手动的慢。优缺点同样明显。<br />http://archive.cnblogs.com/a/1900652/-------->手动维护堆!<br />#include<iostream> #include<cst原创 2011-03-14 09:26:00 · 470 阅读 · 0 评论 -
STL之multiset应用。
要求:可添加,可删除最大、最小的数,可查询当前最大、最小的数。#include #include #include #include using namespace std; int main() { int a,b;int c,d; int i=0; char ch[4]; scanf("%d%d",&a,&b); getchar(); multiset tree; tree.clear (); multiset::iter原创 2011-05-12 00:51:00 · 583 阅读 · 0 评论 -
poj3253——Fence Repair
<br />哈夫曼树应用。<br />思路:优先队列模拟。注意数据范围!<br />#include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; int main() { priority_queue<long long ,vector<long long >,greater<long long > >tree; int n; long long a,b,sumab原创 2011-03-24 21:04:00 · 431 阅读 · 0 评论 -
set的简单用法
#include #include using namespace std; settt; set::iterator it,pre;//迭代器 int main() { int i; for(i=0;i tt.insert(i); it=tt.find (0);//找到数0 //cout pre=tt.begin (); while(pre!=tt.end ())//将所有数输出 { co原创 2011-04-03 12:28:00 · 793 阅读 · 2 评论 -
string而非cstring
<br />c++的类库太强大了!给力!<br />#include<iostream> #include<cstdio> #include<string> #include<set> using namespace std; string cla="class",be="begin",end="end",sub="Sub",def="def",call="call",undef="undef"; string ch,t1,t2; set<string> duck; set<string>:原创 2011-04-04 20:27:00 · 455 阅读 · 0 评论 -
poj1101——The Game//优先队列
bfs+priority_queue可过。就说些注意点:1,priority_queue默认为升序,要重构"2,不要用vis[][]标记走过的点,因为有些点可能要多次访问;3,方向相反时,当做一次转向。#include#include#includeusing namespace std;#define maxn 80int dir[][2]={{-1,0},{原创 2011-06-28 13:24:00 · 804 阅读 · 0 评论 -
poj1811——Prime Test//素数判断+整数分解因子
题意:给定N,如果N为素数,输出“Prime”,否则输出其最小因子。思路:用miller_rabin判断素数,pollardRho用于整数因子的分解。整数因子分解还有一个更快的算法:SQUFOF。#include#include#include#include#include#define time 8#define call 200using namespace std;__in原创 2011-07-02 19:33:00 · 826 阅读 · 0 评论 -
贪吃蛇游戏
模仿http://zhidao.baidu.com/link?url=73YIrvyI57-_a7ur1H2rK1xjdK8oeTnUu28z6bL0hD28HOaLeeRoEYCh3p2YRTrKM0NP20atWAdFhnOklpMGn_ #include #include #include #include #include using namespace std; #define N原创 2014-03-15 21:49:03 · 854 阅读 · 0 评论