bnuoj 20838 Item-Based Recommendation (模拟)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=20838
【题意】:
有点长,略。
【code】:
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm> using namespace std; double rat[][];
double drat[][]; struct Nod
{
int id;
double rt;
}node[]; int m,n; bool cmp(Nod a,Nod b)
{
return a.rt>b.rt;
} double getAns(int a,int b)
{
int i;
double sum=;
for(i=;i<=n;i++)
{
if(rat[i][a]>&&rat[i][b]>)
{
sum+=(rat[i][a]-rat[i][b])*(rat[i][a]-rat[i][b]);
}
}
return 1.0/(sum+);
} void getDrat()
{
int i,j;
for(i=;i<=m;i++)
{
drat[i][i]=;
for(j=i+;j<=m;j++)
{
drat[i][j]=drat[j][i]=getAns(i,j);
}
}
} int main()
{
int c;
scanf("%d%d%d",&n,&m,&c);
memset(rat,,sizeof(rat));
while(c--)
{
int a,b;
scanf("%d%d",&a,&b);
scanf("%lf",&rat[a][b]);
}
getDrat();
int x;
while(~scanf("%d",&x))
{
printf("Recommendations for user %d:\n",x);
int i,cnt=,j;
double down=,up=;
for(i=;i<=m;i++)
{
if(rat[x][i]==)//i=6
{
down=,up=;
for(j=;j<=m;j++)
{
if(rat[x][j]>)
{
down+=drat[i][j];
up+=drat[i][j]*rat[x][j];
}
}
node[cnt].id = i;
node[cnt].rt = up/down;
cnt++;
}
}
sort(node,node+cnt,cmp);
for(i=;i<cnt&&i<;i++)
{
printf("%d %.3lf\n",node[i].id,node[i].rt);
}
putchar();
}
return ;
}
bnuoj 20838 Item-Based Recommendation (模拟)的更多相关文章
- bnuoj 29373 Key Logger(模拟双向队列)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29373 [题意]:模拟光标输入 [题解]:用双向列表模拟实现,这里用其他模拟会超时,注意内存的释放 ...
- (转) Quick Guide to Build a Recommendation Engine in Python
本文转自:http://www.analyticsvidhya.com/blog/2016/06/quick-guide-build-recommendation-engine-python/ Int ...
- Recommendation system
Dear Prof.Choi: My research interest is mainly the application and optimization of big data and arti ...
- 论文笔记: Deep Learning based Recommender System: A Survey and New Perspectives
(聊两句,突然记起来以前一个学长说的看论文要能够把论文的亮点挖掘出来,合理的进行概括23333) 传统的推荐系统方法获取的user-item关系并不能获取其中非线性以及非平凡的信息,获取非线性以及非平 ...
- Understanding Item Import and Debugging Problems with Item Import (Doc ID 268968.1)
In this Document Purpose Details Scenario 1: Testing the basic item import with minimum columns po ...
- Use of Deep Learning in Modern Recommendation System: A Summary of Recent Works(笔记)
注意:论文中,很多的地方出现baseline,可以理解为参照物的意思,但是在论文中,我们还是直接将它称之为基线,也 就是对照物,参照物. 这片论文中,作者没有去做实际的实验,但是却做了一件很有意义的事 ...
- c#取得post和get的数据和模拟发送
可以放在控制器的入口函数中,这样载入就会被调用 asp.net mvc,get+post: public ActionResult Index() { ) { foreach (var item in ...
- PyQt学习随笔:Qt中tem Views(Model-Based)和Item Widgets(Item-Based)控件的用途和关系
在界面程序开发中,数据的展示主要包括表格.简单列表.树状列表以及纯文本等多种方式,在Qt中将界面表格.简单列表.树状列表称为"表项视图类(item view class)",并提供 ...
- Mahout推荐算法API详解
转载自:http://blog.fens.me/mahout-recommendation-api/ Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, ...
随机推荐
- poj 1904 强连通分量
思路:先有每个儿子向所有他喜欢的姑娘建边,对于最后给出的正确匹配,我们建由姑娘到相应王子的边.和某个王子在同一强连通分量,且王子喜欢的姑娘都是该王子能娶得.思想类似匈牙利算法求匹配的时候,总能找到增广 ...
- CSS3—六边形
整理了2种方法,看完肯定觉得超简单~ 一.旋转型 话不多说先看下需要的样式: 1.transform:rotate(angle) 2.overflow 3.visibility 效果:演示效果,run ...
- (转载)运行主机管理在openvswitch之上
在这篇文章里介绍了如果运行主机管理在openvswitch之上,而不是单独配置一个物理网卡用于主机管理,并且所有的vm的流量还是通过openvswitch走的. Running Host Manage ...
- Java Concurrency - 浅析 Phaser 的用法
One of the most complex and powerful functionalities offered by the Java concurrency API is the abil ...
- Slickflow.NET 开源工作流引擎基础介绍(三) -- 基于HTML5/Bootstrap的Web流程设计器
1. Slickflow Designer 技术优势 1) 基于HTML5技术,兼容常见浏览器; 2) 纯Javascript / JsPlumb 脚本实现SVG图形化显示; JsPlumb允许您使用 ...
- js前端防止默认表单提交
代码如下: document.forms[0].onsubmit=function(){return false;};
- jQuery API 3.1.0 速查表-打印版
jQuery API 3.1.0 速查表-打印图,(API来自:http://jquery.cuishifeng.cn/index.html)
- java坑之无法创建线程
环境:linux 错误:java.lang.OutOfMemoryError: unable to create new native thread 原因:OS对线程是有限制 解决办法: 在Linux ...
- OpenGL3-绘制各种图元绘制
代码下载 #include "CELLWinApp.hpp"#include <gl/GLU.h>#include <assert.h>#include & ...
- (POJ 3694) Network 求桥个数
题目链接:http://poj.org/problem?id=3694Description A network administrator manages a large network. The ...