- 浏览: 41476 次
- 性别:
最近访客 更多访客>>
最新评论
-
zsybupt:
...
boj 591 -
zzy7186:
写得好。。。 [size=x-small][/size]
hadoop:no namenode to stop及其他
文章列表
dfs,另外用dp[k][x1][y1][x2][y2]进行标记
#include<iostream>
#include<cmath>
using namespace std;
#define N 20
double G[10][10],dp[20][10][10][10][10];//棋盘;
double e;
double f(int x1,int y1,int x2,int y2)
{
return (G[x2][y2]-G[x1-1][y2]-G[x2][y1-1]+G[x1-1][y1-1])*(G[x2][y2]-G[x1-1] ...
并查集---可能是我水过最多的算法。。。。
#include<iostream>
using namespace std;
#define N 50005
#define M 105
int colorClass[N];
int father[M];
int findFather(int i)
{
if(father[i]!=i)
father[i]=findFather(father[i]);
return father[i];
}
void union_set(int a,int b)
{
int fa=findFather(a ...
蛋疼的晚上打开一道题boj 591,发现就是辗转相除法,求系数。。。然后先是输出“Not Exist”打错为“No Exist”,后来又少写return 0;狗血。。。。。。
#include<iostream>
using namespace std;
int judge(int max,int min,int &first,int &second)//辗转相除 max*first+min*second = 1
{
if(max%min==0)
return 0;
if(max%min==1)
{
int tmp = max/m ...
dp,k位的以i∈[0,9]开头的no-decreasing Num的个数为
dp[k][i]=dp[k-1][i]+dp[k-1][i+1]+...+dp[k-1][9],
对于输入的n
只需输出dp[n+1][0]即可
#include<iostream>
using namespace std;
#define N 66
long long dp[N][10];
int main()
{
for(int i=0;i<=9;i++)
dp[1][i]=1;
for(int i=2;i<N;i++)
{
for(int ...
水题,读入数据时注意,开始以回车作为结束,发现坑爹,还是计数靠谱,输出格式也要注意
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
while(n!=1)
{
int s=0,r=0,c=0;
char ch;
int cnt=0;
ch=getchar();
ch=getchar();
while(cnt<n-1)
{
if(ch=='S')
{
s ...
只需寻找到连续的两个序列时,一个pawn上去消灭一个rook。但是选取哪个pawn上去的时候要根据以下原则,其实就是为了连续序列时能消灭更多的rook
if(curPawnsCol[j]<curPawnsCol[j+1])
curPawnsCol[j+1]--;
else
curPawnsCol[j]--;
代码:
#include<iostream>
using namespace std;
#define N 1002
#define M 1002
int curPawnsCol[M];
int mai ...
POJ 1734(找最小环)
一道很经典的Floyd的拓展,注意第一层里的循环顺序,看懂以后你会赞叹Floyd的奇妙!
题意:给出一张无向图,求一个最小环并输出路径。
http://proverbs.diandian.com/post/2012-05-10/18185390
#include <cstdio>
#include <cstring>
#include <iostream>
#define find_min(a,b) a<b?a:b
using namespace std;
const int N ...
http://acm.bupt.edu.cn/onlinejudge/newoj/showProblem/show_problem.php?problem_id=24
作为一个水货,只能水过。。。
找时间看下划分树和线段树等算法吧。。。
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
int no;
int value;
};
node x[100002];
int tmp[100002];
int Q[5002][2];
int cm ...
11月19号准备做的题。。。拖了2个月。。。。
http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=17253#problem/G
还是想清楚再敲码,不然后面再修修补补容易出错。。。
#include<iostream>
#include<stdio.h>
using namespace std;
int f[304][304];
int data[304];
bool judge[304][304];
int main( )
{
int n,m;
while(scan ...
Apache Commons CLI 的运用
- 博客分类:
- hadoop
在学习Mahout中Kmeans源码中,了解了大概的结构,了解到对于输入接口,Mahout应该是在apache的Options(org.apache.commons.cli)基础上,实现了自己的Options(org.apache.commons.cli2)。查阅相关资料,大致了解了apache的Options,写了个简单的例子。
package Etl;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commo ...
Hadoop自定义类型的输出
- 博客分类:
- hadoop
在上篇中,有一个错误的地方,就是对于自定义类型,在TextOutputFormat输出格式下输出的时候,会出现不正常的情况。后来查看TextOutputFormat的源码发现,在输出的时候,它会调用自定义类型VectorWritable的toString方法。以前也写过,不知道为什么不正常,这次添加toString方法后,输出文件中显示正常。
TextOutputFormat中调用Object.toString:
private void writeObject(Object o) throws IOException {
if (o instanceof Te ...
hadoop自定义类型
- 博客分类:
- hadoop
hadoop为用户提供了自定义类型的接口,对于key,需要重写实现WritableComparable,而对于value,只需重写实现Writable即可。但是在作为reduce的输出的时,输出格式为TextOutputFormat时,不能正常显示。还需要自定义OutputFormat。
常用的几个函数:
private double []values = null;
public VectorWritable(){}
public VectorWritable(double []a){
this.values =a;
}
public double ...
以上为FSDataInputStream的继承结构图,他的定义为:
public class FSDataInputStreamextends DataInputStreamimplements , , CloseableFSDataInputStream的主要作用就是用DataInputStream包装了一个输入流,并且使用
在重隔几个月后重新启动hadoop时,发现namenode启动不了(在bin/stop-all.sh时提示no namenode to stop),上网搜寻no namenode to stop 发现各种各样的解决问题的方法,例如format namenode...等等,发现都不管用。自己还是不够耐心,一气之下就把hadoop和cygwin和jdk全部重装了一遍。下面记录下需要注意的一些事项:
1):jdk在安装的时候一定要选择全英文,且路径中没有空格出现,比如最好就不要安装到C:\Program Files\底下,因为这样会影响到后面hadoop-env.sh.
...