01背包问题,并打印出路径
#include
#include
using namespace std;
#define MAX 100
int f[MAX][MAX];
int Path[MAX][MAX];
int main()
{
int Weight[] = {0,2,3,1,4,6,5};
int Value[] = {0,5,6,5,1,19,7};
in...
分类:
其他好文 时间:
2015-08-07 20:15:22
阅读次数:
117
//文件
/*
===============================================================
题目:从文本文件中找出最长和最短的行输出在屏幕上,并统计文件中
共有多少行?
===============================================================
*/
#include
#incl...
分类:
编程语言 时间:
2015-08-07 20:14:33
阅读次数:
148
//有3个国家名,找出按字母顺序排在最前面的国家字符串
代码如下:
#include
#include
using namespace std;
int main()
{
void smallest_string(char str[ ][30],int i);//函数声明
int i;
char country_name[3][30];//定义二维字符数组,把一个二...
分类:
编程语言 时间:
2015-08-07 20:13:51
阅读次数:
130
学算法之后,Ac的第一道题。
分析:当i%(i-p[i])==0&&p[i]!=0时,字符串结束循环。并且,偱环节长度为 i-p[i],循环次数为
i/(i-p[i]).
#include
#include
int len;
int p[1000010];
char str[1000010];
void getp()
{
int i=0,j=-1;
p[i]=j;
w...
分类:
其他好文 时间:
2015-08-07 20:08:14
阅读次数:
125
//所谓线索二叉树无非是为了让原本指向NULL的节点指向一个具体的
//已经存在的节点,逻辑上实现指针的无空指向的实现,下面是我中
//序线索二叉树的实现。还是把先序线索二叉树与后序线索分开来写吧。#include
using namespace std;template
struct Node
{
Type data;
bool r...
分类:
其他好文 时间:
2015-08-07 20:08:00
阅读次数:
106
最后结论:
Grey = (R*38 + G*75 + B*15)>> 7
代码
#include
#include
using namespace cv;
int main(){
Mat src= imread("C:\\Users\\Poplar\\Pictures\\ff.jpg");
Matgrey(src.rows, src.cols...
分类:
其他好文 时间:
2015-08-07 20:07:56
阅读次数:
207
题目链接:点击进入
这道题就不能简单的套模板了,因为他是要判断给定的区间里有多少个值小于H。思路看完题后就有了,其实我们只要二分名次k,然后将得到的值与H进行比较就行了,这样就可以求出一个高度恰好小于H的名次作为答案了。但要注意一下,使用划分树求出的第k大值,其实是第k小值,开始就被被这一点坑了。代码如下:#include
#include
#include<c...
分类:
其他好文 时间:
2015-08-07 20:07:49
阅读次数:
91
UVA - 12874 Blanket题意: 给你n个毯子,m个人,并给你每条毯子厚的部分的长度和该厚的部分出现的周期;
求盖了0--n 个毯子的人数。
代码:#include
#include
#include
#include
#include
#include
#inclu...
分类:
其他好文 时间:
2015-08-07 20:07:24
阅读次数:
106
#include
int x[80000];
int main()
{
int s,t,n,m,a;
long long r;
freopen("sample_input.txt","r",stdin);
scanf("%d",&t);
for(s=1;s<=t;s++)
{
scanf("%d",&n);
m=-1;r...
分类:
编程语言 时间:
2015-08-07 20:03:59
阅读次数:
130
并查集
想法很简单
开两个数组
吃 与 被吃
然而 炸了我一下午
mlgb
贴个错误代码
吃饭去了
烦
#include
#include
#include
using namespace std;
const int maxn=55555;
int fa[maxn];
int eat[maxn];
int ate[maxn];
int find(int x)
{
...
分类:
其他好文 时间:
2015-08-07 20:03:09
阅读次数:
85