码迷,mamicode.com
首页 >  
搜索关键字:namespace    ( 41927个结果
hdoj Cow Sorting
题意:给你n个无序的数,通过相邻的两个数交换,交换的价值是两个数之和,求使之increasing order的最小代价和 与poj3270不同的是poj可以每个数任意交换,可以用置换群来做 #include #include #include #include #include using namespace std; #define ll __int64 #define N 100000+1...
分类:其他好文   时间:2015-04-14 10:01:37    阅读次数:129
hdoj 4911 Inversion 树状数组+离散化
题意:给你n个可以重复的无序数列,问经过k次相邻交换后最少还有多少对逆序数 求逆序对可以用树状数组来做,对于重复的元素,可能在sort的时候交换编号 求和的时候要注意去重,还有一种方法就是稳定排序stable_sort #include #include #include using namespace std; #define ll __int64 #define N 100000+10 ...
分类:编程语言   时间:2015-04-14 10:01:37    阅读次数:132
C求解一个数二进制1的个数
#include using namespace std; int Grail(int x) { int N=0; while(x) { x=x&(x-1); N++; } return N; } int main() { cout<<Grail(7)<<endl; //0111 //0110 //0101 //0100 //0100 //0011 ret...
分类:其他好文   时间:2015-04-14 10:01:12    阅读次数:103
SPOJ DISUBSTR Distinct Substrings
后缀数组水题 先求所有的子串数,根据长度枚举,共(n+1)*n/2种 当height[i]>0时,说明height[i]这个前缀与其他子串相同,减去这height[i]个子串 #include #include #include using namespace std; #define N 1005 int r[N],sa[N],height[N],rank[N],wa[N],wb[N],w...
分类:其他好文   时间:2015-04-14 09:59:40    阅读次数:125
NYOJ 860 又见01背包
有n个重量和价值分别为wi 和 vi 的 物品,从这些物品中选择总重量不超过 W的物品,求所有挑选方案中物品价值总和的最大值。 1 2 #include 3 #include 4 #include 5 using namespace std; 6 const int MAX = 0x3fffff.....
分类:其他好文   时间:2015-04-14 09:52:53    阅读次数:112
[c++]友元函数的应用
其中有2个类:一个是深圳类shen_stock,一个是上海类shang_stock,类中有3个私有成员:普通股票个数general,ST股票个数st和PT股票个数pt,每个类分别有自己的友元函数来计算并显示深圳或上海的股票总数(3项的和)。两个类还公用一个函数count(),用来计算深圳和上海总共有多少股票并输出 #include using namespace std; class shen_...
分类:编程语言   时间:2015-04-14 08:37:24    阅读次数:180
POJ1007--DNA Sorting
#include #include #include using namespace std; int n,m; struct e { char a[200]; int id; int px; }s[200]; int cmp(e s1,e s2) { if(s1.px==s2.px) return s1.id<s2.id; else return s1....
分类:其他好文   时间:2015-04-14 08:35:35    阅读次数:171
【最短路】【最大流】bzoj3931 [CQOI2015]网络吞吐量
跑出最短路图,然后把结点拆点跑最大流。#include#include#include#include#includeusing namespace std;#define M 100001#define INF 2147483647#define N 501typedef long long ll...
分类:其他好文   时间:2015-04-14 08:27:42    阅读次数:145
函数数组排序带出最大最小值及平均值
namespace 函数数组排序带出最大最小值及平均值{ class Program { static void Main(string[] args) { int[] b=new int[]{9,1,5,3,7}; int max = 0; //设置两个变量用来接收最低值与最小值。 int mi....
分类:编程语言   时间:2015-04-14 01:56:57    阅读次数:143
函数——返回值不止一个的情况(解一元二次方程)
namespace 一元二次方程函数解决{ class Program { static void Main(string[] args) { while (true) { Console.WriteLine("请为一元二次方程ax²+bx+c设置相关参数:"); Console.WriteLin....
分类:其他好文   时间:2015-04-14 01:56:19    阅读次数:164
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!