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, ...
随机推荐
- 转: android studio 消除SDK更新时的“https://dl-ssl.google.com refused”错误
消除了: hostname in certificate didn't match: 转: http://blog.csdn.net/gaojinshan/article/details/987160 ...
- [原创] CSS总结!! 有关HTML第二篇 !!
同样是拿xMind写的 明天上传 CSS+DIV 总结 今天只有CSS了 但是首先涉及一下浏览器原理: 还有好多不知道的模块 但是页面的核心模块就这些了:(些许 需要补充 请关照 ) / ...
- oracle的nvl和sql server的isnull
最近公司在做Oracle数据库相关产品,在这里作以小结: ISNULL()函数 语法 ISNULL ( check_expression , replacement_value) 参数 c ...
- Asp.Net MVC 路由 【转】
原文链接:http://www.asp.net/learn/mvc/ 在这篇教程中,我将为你介绍每个ASP.NET MVC应用程序都具有的一个重要功能,称作ASP.NET路由(ASP.NET Rout ...
- ActiveMQ(5.10.0) - Configuring the Simple Authentication Plug-in
The easiest way to secure the broker is through the use of authentication credentials placed directl ...
- GPU总结(1)
目录 1.为什么要引入GPU 2.CUDA环境的搭建--CUDA全称Compute Unified Device Architecture统一计算设备架构,CUDA是以后总将GPU作为数据并行计算设备 ...
- JDBC(用Eclipse操作数据库Oracle)的基础操作集合
JDBC: JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java语言编 ...
- 第十一篇、RxSwift
三. 什么是函数式编程? 什么是函数式编程呢? 函数式编程其实是一种编程思想, 代码写出来只是它的表现形式. 在面向对象的编程思想中, 我们将要解决的一个个问题, 抽象成一个个类, 通过给类定义属性和 ...
- MAF+WPF实现插件式应用程序框架
关于maf和wpf大家感兴趣的话可以去百度学习一下,下面展示一下成果: 登录界面 主界面:默认的是我的应用,表示已经下载到本地的应用. 辅助应用类似appstore功能,指示未下载或者需要升级的程序列 ...
- c# 两个数组比较,将重复部分去掉,返回不重复部分
List<string> Ashuzu = new List<string>(); Ashuzu.Add("); Ashuzu.Add("); List&l ...