Acperience HDU - 5734
Convolutional neural networks show reliable results on object recognition and detection that are useful in real world applications. Concurrent to the recent progress in recognition, interesting advancements have been happening in virtual reality (VR by Oculus), augmented reality (AR by HoloLens), and smart wearable devices. Putting these two pieces together, we argue that it is the right time to equip smart portable devices with the power of state-of-the-art recognition systems. However, CNN-based recognition systems need large amounts of memory and computational power. While they perform well on expensive, GPU-based machines, they are often unsuitable for smaller devices like cell phones and embedded electronics.
In order to simplify the networks, Professor Zhang tries to introduce simple, efficient, and accurate approximations to CNNs by binarizing the weights. Professor Zhang needs your help.
More specifically, you are given a weighted vector W=(w1,w2,...,wn)W=(w1,w2,...,wn). Professor Zhang would like to find a binary vector B=(b1,b2,...,bn)B=(b1,b2,...,bn) (bi∈{+1,−1})(bi∈{+1,−1}) and a scaling factor α≥0α≥0in such a manner that ∥W−αB∥2‖W−αB‖2 is minimum.
Note that ∥⋅∥‖⋅‖ denotes the Euclidean norm (i.e. ∥X∥=x21+⋯+x2n−−−−−−−−−−−√‖X‖=x12+⋯+xn2, where X=(x1,x2,...,xn)X=(x1,x2,...,xn)).
InputThere are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:
The first line contains an integers nn (1≤n≤100000)(1≤n≤100000) -- the length of the vector. The next line contains nn integers: w1,w2,...,wnw1,w2,...,wn (−10000≤wi≤10000)(−10000≤wi≤10000).OutputFor each test case, output the minimum value of ∥W−αB∥2‖W−αB‖2 as an irreducible fraction "pp/qq" where pp, qq are integers, q>0q>0.Sample Input
3
4
1 2 3 4
4
2 2 2 2
5
5 6 2 3 4
Sample Output
5/1
0/1
10/1 一个公式推导题
最后的是式子为n* (x1^2+x2^2+…….+xn^2) - sum*sum
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include <vector>
#include<math.h>
using namespace std;
long long gcd(long long a,long long b)
{
if (a==) return b;
else gcd(b%a,a);
}
int main()
{
int t;
while(scanf("%d",&t)!=EOF){
while(t--){
int n,a;
scanf("%d",&n);
long long ans=,cnt=,sum=;
for (int i= ;i<n ;i++){
scanf("%d",&a);
a=abs(a);
ans+=a;
cnt+=a*a;
}
ans=ans*ans;
sum=n*cnt-ans;
long long b=gcd(sum,n);
printf("%lld/%lld\n",sum/b,n/b);
}
}
return ;
}
Acperience HDU - 5734的更多相关文章
- HDU 5734 Acperience(返虚入浑)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5734 Acperience (推导)
Acperience 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...
- hdu 5734 Acperience 水题
Acperience 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...
- HDU 5734 Acperience
Acperience Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 5734 A - Acperience
http://acm.hdu.edu.cn/showproblem.php?pid=5734 Problem Description Deep neural networks (DNN) have s ...
- hdu 5734 Acperience(2016多校第二场)
Acperience Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 5734 Acperience (公式推导) 2016杭电多校联合第二场
题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cs ...
- HDU 5734 Acperience(数学推导)
Problem Description Deep neural networks (DNN) have shown significant improvements in several applic ...
- HDU 5734 Acperience ( 数学公式推导、一元二次方程 )
题目链接 题意 : 给出 n 维向量 W.要你构造一个 n 维向量 B = ( b1.b2.b3 ..... ) ( bi ∈ { +1, -1 } ) .然后求出对于一个常数 α > 0 使得 ...
随机推荐
- 51NOD 1584 加权约数和 [莫比乌斯反演 转化 Trick]
1584 加权约数和 题意:求\(\sum_{i=1}^{N} \sum_{j=1}^{N} {\max(i,j)\cdot \sigma(i\cdot j)}\) 多组数据\(n \le 10^6, ...
- BZOJ 2083: [Poi2010]Intelligence test [vector+二分]
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- 简单实现ASP.Net MVC网页播放音乐
<div> @*音乐*@ <audio id="warning-sound" loop="loop" src="/Areas/Map ...
- CentOS上安装Git服务器
1.安装Git 打开控制台,执行以下命令进行安装 $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel ...
- qt实现一个简单的计算器
1.计算器的界面如下图所示 dalog.cpp #include "dialog.h" #include "ui_dialog.h" #include<Q ...
- 把页面的Table直接输出到Excel文件中
有个需求是统计的时候,为生成的html表格提供导出功能,但是这样导出Excel不会显示自身的表格 影响美观,但是excel会显示html的css样式,这里可以通过处理行对象的方式进行导出,但是处理起纵 ...
- Quartz.NET 3.0 正式发布
Quartz.NET是一个强大.开源.轻量的作业调度框架,你能够用它来为执行一个作业而创建简单的或复杂的作业调度.它有很多特征,如:数据库支持,集群,插件,支持cron-like表达式等等.在2017 ...
- Ubuntu16.04+Apache虚拟主机配置详解
在window下,Apache的配置文件是httpd.conf,但在Linux下安装了Apache后发现其配置并不像window下那么简单,Linux下Apache将各个设置项分在了不同的配置文件中, ...
- Linux 安装配置 FTP 服务 (vsftpd)
1. 安装 vsftpd yum install vsftpd -y 2. 创建用户 record adduser -s /bin/nologin -d /var/RecordFile/ record ...
- CENTOS6.6 下mysql MHA架构搭建
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 本篇是自己搭建的一篇mysql MHA文章 前面的安装步骤基 ...