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, ...
随机推荐
- extjs的调试方法
1.使用extjs自带的测试工具 第一步:在ExtJS下载的资源包中,找到debug.js,将JS文件导入实际要运行的HTML或者JSP页面上 第二步:在有关JS文件代码中嵌入Ext.log('自定义 ...
- PowerShell 解锁使用浏览器下载的文件
1 dir *.* -Recurse | Unblock-File
- 面试之SQL(1)--选出选课数量>=2的学号
ID Course 1 AA 1 BB 2 AA 2 BB 2 CC 3 AA 3 BB 3 CC 3 DD 4 AA NULL NULL 选出选课数量>=2的学号 selectdis ...
- Genymotion安卓模拟器,性能最好
老笔记本用AndroidSDK自带的模拟器 启动慢 运行卡 用了Genymotion启动快,运行响应媲美真机 想起学生时代,那时候智能手机还未完全普及 也用模拟器玩过”电脑里的手机“.
- Ssqlserver 关于Grouping sets
sqlserver2008之后引入Grouping sets是group by的增强版本,Grouping sets 在遇到多个条件时,聚合是一次性从数据库中取出所有需要操作的数据,在内存中对数据库进 ...
- Android之文字点击链接
定义textView1和textView2并获得组件. String html = "<font color='red'></font>"; html += ...
- Apache配置多端口多站点
配置httpd.conf 监听多个端口 复制代码 代码如下:# Listen: Allows you to bind Apache to specific IP addresses and/or # ...
- BT之下拉菜单
<div class="dropdown"> <button class="btn btn-default dropdown-toggle" ...
- Redis配置中文翻译,3.2.1版
大部分常见设置都翻译了,还有一些是从网上复制的(懒) # Redis configuration file example. ## Redis配置文件示例 # # Note that in order ...
- 使用JavaScript实现简单的输入校验
HTML页面代码: <!doctype html> <html lang="en"> <head> <meta charset=" ...