Page Rank

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)

Total Submission(s): 280    Accepted Submission(s): 75

Problem Description
Evaluation and rank of web pages is a hot topic for many internet companies and researchers. PageRank is a link analysis tool and it assigns a numerical weighting to each element of a hyperlinked set of documents, such as the World Wide Web, with the purpose
of "measuring" its relative importance within the set. The algorithm may be applied to any collection of entities with reciprocal quotations and references. The numerical weight that it assigns to any given element E is referred to as the PageRank of E and
denoted by . Other factors like Author Rank can contribute to the importance of an entity.



For simplicity, in this problem PageRank vector q is defined as q = Gq, Where , S is the destination-by-source stochastic matrix, U is all one matrix, n is the number of
nodes and α is the weight between 0 and 1 (here we use 0.85).



For the example on the right, we have:








Denote the current PageRank vector and the next PageRank vector by qcur and qnext respectively. The process is to compute the iterative powering for finding the first eigenvector.








The computation ends until  for some small ε(10-10).
 
Input
The input contains many test cases. 



For each case, there are multiple lines. The first line contains an integer N(N<=3000), which represents the number of pages. Then a N*N zero-one matrix follows. The element Eij (0 <= i, j < N) on the matrix represents whether the i-th page has a
hyper link to the j-th page.
 
Output
Output one line with the eigenvector. The numbers should be separated by a space and be correctly rounded to two decimal places.
 
Sample Input
4
0111
0011
0001
0100
 
Sample Output
0.15 1.49 0.83 1.53
 
Source
 
Recommend
 
模拟,,,
add函数没有卵用。。
ac代码
Problem : 5097 ( Page Rank )     Judge Status : Accepted
RunId : 14492913 Language : C++ Author : lwj1994
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include<stdio.h>
#include<string.h>
#include<math.h>
#define eps 1e-10
char map[3030];
double ans[3030][3030];
double q[2][3030];
int n;
void muti(double a[][3030],double num)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
a[i][j]*=num;
}
}
void add(double a[][3030],double b[][3030])
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
a[i][j]+=b[i][j];
}
}
int jud()
{
double ans=0;
int i;
for(i=0;i<n;i++)
{
ans+=(q[0][i]-q[1][i])*(q[0][i]-q[1][i]);
}
//ans=sqrt(ans);
if(fabs(ans)<eps)
return 1;
return 0;
}
int main()
{
//int n;
while(scanf("%d",&n)!=EOF)
{
int i,j;
double a=0.85;
memset(ans,0,sizeof(ans));
for(i=0;i<n;i++)
{
int sum=0;
scanf("%s",&map);
for(j=0;j<n;j++)
{
if(map[j]=='1')
sum++;
//U[i][j]=1;
}
for(j=0;j<n;j++)
{
if(map[j]=='1')
ans[j][i]=1.0/sum;
}
}
muti(ans,a);
// muti(U,1.0/n*(0.15));
// printf("\n");
// add(ans,U);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
ans[i][j]+=(0.15/n);
int p=0;
for(i=0;i<n;i++)
{
q[p][i]=1;
q[p^1][i]=0;
}
//mmuti(q[p],ans,q[p^1]);
//p^=1;
while(!jud())
{
//q[p^1]=mmuti(q[p],ans);
for(i=0;i<n;i++)
{
q[p^1][i]=0;
for(j=0;j<n;j++)
q[p^1][i]+=q[p][j]*ans[i][j];
}
p^=1;
}
printf("%.2lf",q[p][0]);
for(i=1;i<n;i++)
{
printf(" %.2lf",q[p][i]);
}
printf("\n");
}
}

HDOJ 题目5097 Page Rank(矩阵运算,模拟)的更多相关文章

  1. HDU 5097 Page Rank (模拟)

    题目背景是以前用来对网页进行排名的Page Rank算法,是早期Google的革命性发明. 背后的原理是矩阵和图论.这个数学模型是由Google的创始人拉里·佩奇和谢尔盖·布林发现的. 如果一个网页被 ...

  2. 杭电hdoj题目分类

    HDOJ 题目分类 //分类不是绝对的 //"*" 表示好题,需要多次回味 //"?"表示结论是正确的,但还停留在模块阶 段,需要理解,证明. //简单题看到就 ...

  3. HDOJ 题目分类

    HDOJ 题目分类 /* * 一:简单题 */ 1000:    入门用:1001:    用高斯求和公式要防溢出1004:1012:1013:    对9取余好了1017:1021:1027:   ...

  4. [IR课程笔记]Page Rank

    主要目的: 在网络信息检索中,对每个文档的重要性作出评价. Basic Idea: 如果有许多网页链接到某一个网页,那么这个网页比较重要. 如果某个网页被一个权重较大的网页链接,那么这个网页比较重要. ...

  5. 【HDOJ】5096 ACM Rank

    Treap+set仿函数重定义.每当ac一道题目时,相当于对总时间减去一个大数. /* 5096 */ #include <iostream> #include <string> ...

  6. HDOJ题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. HDOJ 题目2475 Box(link cut tree去点找祖先)

    Box Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  8. HDOJ 题目3518 Boring counting(后缀数组,求不重叠反复次数最少为2的子串种类数)

    Boring counting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. HDOJ 题目2474 String painter(区间DP)

    String painter Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

随机推荐

  1. HttpClient短信接口

    HttpClient简介 HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 jav ...

  2. node js koa js严格模式

      当前为配置 非原创 引用于“得金” ### nodejs项目配置终端命令 1. 检查本地 nodejs 版本`$node -v` 如果版本低就升级 2. 安装 n 升级命令 `$npm insta ...

  3. Laravel5.1学习笔记3 HTTP中间件

    HTTP 中间件 简介 建立中间件 注册中间件 可终止中间件 简介 HTTP 中间件提供一个方便的机制来过滤进入应用程序的 HTTP 请求,例如,Laravel 默认包含了一个中间件来检验用户身份验证 ...

  4. 打开手机摄像头扫描二维码或条形码全部操作(代码写的不好,请提出指教,共同进步,我只是一个Android的小白)

    (1)下载二维码的库源码 链接:http://pan.baidu.com/s/1pKQyw2n 密码:r5bv 下载完成后打开可以看到 libzxing 的文件夹,最后添加进 Android  Stu ...

  5. 如何写出高性能SQL语句(文章摘自web开发者)

    (声明:本文内容摘自web开发者,仅供收藏学习之用,如有侵权请作者联系博主,博主将在第一时间删除) 原文地址:http://www.admin10000.com/document/484.html 1 ...

  6. openMSP430之openmsp430-loader

    openmsp430-loader This simple program allows the user to load the openMSP430 program memory with an ...

  7. java编程题(一)

    [程序1]    题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? //这是一个菲波拉契数列问题 p ...

  8. 读书笔记「Python编程:从入门到实践」_7.用户输入和while循环

    7.1 函数input()的工作原理 函数input() 让程序暂停运行,等待用户输入一些文本.获取用户输入后,Python将其存储在一个变量中,以方便你使用. message = input(&qu ...

  9. extension Array where Element 代码学习

    var fieldNames: [String] { let p = UnsafePointer<Int32>(self.pointer) return Array(utf8Strings ...

  10. 获取url后面的路径

    function GetUrlRelativePath() { var url = document.location.toString(); var arrUrl = url.split(" ...