随笔分类 -  c++

摘要:functionstd::setprecision<iomanip>/*unspecified*/ setprecision (int n);Set decimal precisionSets the decimal precision to be used to format floating-point values on output operations.Behaves as if member precision were called withn as argument on the stream on which it is inserted/extracted as 阅读全文
posted @ 2013-04-20 20:56 bo_jwolf 阅读(1653) 评论(0) 推荐(0)
摘要:Robberies挺有意思的题目,需要点转化。01背包:每个物品代价是每个银行钱的数目,物品的价值是在该银行不被抓的概率 (1-被抓概率),背包容量是所有银行钱的总和。01背包求dp[i]表示获得i的钱不被抓的最大概率。最后从大到小枚举出 dp[i]>=(1-P)这个i就是答案了。关键在于理解题目意思。。。另外需要活学活用,01背包中不可以生搬硬套,这里变成*weight;// File Name: hdu2955.cpp // Author: rudolf // Created Time: 2013年04月20日 星期六 19时34分14秒 #include<vector> 阅读全文
posted @ 2013-04-20 19:44 bo_jwolf 阅读(157) 评论(0) 推荐(0)
摘要:饭卡打啵固态思维,转换成01背包问题,学习人家dp的排版先01背包算出用m-5元可以买到最贵的菜,然后就会一次买最贵的。// File Name: hdu2546.cpp // Author: rudolf // Created Time: 2013年04月20日 星期六 18时51分53秒 #include<iostream> #include<algorithm> #include<string.h> using namespace std; const int maxn=1010; int dp[maxn]; int value[maxn],weigh 阅读全文
posted @ 2013-04-20 19:03 bo_jwolf 阅读(117) 评论(0) 推荐(0)
摘要:Charm Bracelet01背包,打啵固态,背包重来// File Name: poj3624.cpp // Author: rudolf // Created Time: 2013年04月20日 星期六 18时17分21秒 #include<vector> #include<list> #include<map> #include<set> #include<deque> #include<stack> #include<bitset> #include<algorithm> #include 阅读全文
posted @ 2013-04-20 18:19 bo_jwolf 阅读(205) 评论(0) 推荐(0)
摘要:Doing Homework again// File Name: hdu1789.cpp // Author: rudolf // Created Time: 2013年04月20日 星期六 15时52分23秒 #include<vector> #include<list> #include<map> #include<set> #include<deque> #include<stack> #include<bitset> #include<algorithm> #include<func 阅读全文
posted @ 2013-04-20 15:58 bo_jwolf 阅读(157) 评论(0) 推荐(0)
摘要:G -QS Network读懂题意,就都是是水题#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <algorithm> #define N 1001 const int maxn=(N*N-N) / 2 + 1; using namespace std; struct edge { int x, y, value; }edge[maxn]; int n, len, 阅读全文
posted @ 2013-04-20 14:16 bo_jwolf 阅读(173) 评论(0) 推荐(0)
摘要:I -Arctic Network#include<iostream> #include<algorithm> using namespace std; const int maxn=6000; int n; int mapp[maxn][maxn]; struct node { int x,y,value; }edge[maxn]; int fa[maxn]; bool cmp(const node a,const node b) { return a.value<b.value; } int find(int x) { return x==fa[x]?x:fi 阅读全文
posted @ 2013-04-19 20:57 bo_jwolf 阅读(172) 评论(0) 推荐(0)
摘要:B -Network这个题目真坑,用G++居然TLE,用c++ 直接A了,还好在poj直接过了,否则,找错误不得找死啊!!!!#include<iostream> #include<algorithm> using namespace std; const int maxn=15001; struct node { int x,y,value; }edge[maxn]; int fa[maxn]; int find(int x) { return x==fa[x]?x:find(fa[x]); } bool cmp(const node a,const node b) 阅读全文
posted @ 2013-04-19 15:23 bo_jwolf 阅读(160) 评论(0) 推荐(0)
摘要:1. const的最初动机是取代预处理器#define来进行值替代#define只做些文本替代,它既没有类型检查概念,也没有类型检查功能,所以预处理器的值替代会产生一些问题。这些问题在C++中可以通过使用const来避免。2. C++中的const默认为内部连接(internal linkage)const仅在被定义过的文件里才是可见的,而且在连接时不能被其他编译单元看到(默认情况)。3. 当定义一个const时,必须赋一个值给它也就是说,在定义的时候必须要进行初始化。4. const要么保存在符号表中,要么由编译器为其分配存储空间通常C++编译器并不为const创建存储空间,而是把这个定义保 阅读全文
posted @ 2013-04-14 21:25 bo_jwolf 阅读(200) 评论(0) 推荐(0)
摘要:运算符重载常用于解决结构体或是自己定义的类型的加减运算,提供了方便的方式!比如一个类里面的两个整数的相加,可以通过重载运算符+,其次运算符重载常用友元函数实现,可以实现更多的功能!因为友元函数可以访问类的所有成员!先写一个成员函数实现重载'+',睡觉后再写一个友元函数重载的方式!include<iostream> #include<string> #include<cstring> using namespace std; class ST { private : string name; public : void show() { cou 阅读全文
posted @ 2013-04-14 20:39 bo_jwolf 阅读(349) 评论(0) 推荐(0)