Deep neural networks (DNN) have shown significant improvements in several application domains including computer vision and speech recognition. In computer vision, a particular type of DNN, known as Convolutional Neural Networks (CNN), have demonstrated state-of-the-art results in object recognition and detection.

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的更多相关文章

  1. HDU 5734 Acperience(返虚入浑)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. HDU 5734 Acperience (推导)

    Acperience 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...

  3. hdu 5734 Acperience 水题

    Acperience 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...

  4. HDU 5734 Acperience

    Acperience Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  5. HDU 5734 A - Acperience

    http://acm.hdu.edu.cn/showproblem.php?pid=5734 Problem Description Deep neural networks (DNN) have s ...

  6. hdu 5734 Acperience(2016多校第二场)

    Acperience Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  7. HDU 5734 Acperience (公式推导) 2016杭电多校联合第二场

    题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cs ...

  8. HDU 5734 Acperience(数学推导)

    Problem Description Deep neural networks (DNN) have shown significant improvements in several applic ...

  9. HDU 5734 Acperience ( 数学公式推导、一元二次方程 )

    题目链接 题意 : 给出 n 维向量 W.要你构造一个 n 维向量 B = ( b1.b2.b3 ..... ) ( bi ∈ { +1, -1 } ) .然后求出对于一个常数 α > 0 使得 ...

随机推荐

  1. Oracle的order by的中文排序问题

    Oracle 中查询结果按照某个中文字段或者英文字母(包括 符号)排序,并不会得到我们预期的结果,因为对于中文与英文字母及符号,Oracle实际是按照其对应的ASCII码值排序的! 可以看到按照中文村 ...

  2. ES6 学习笔记之一 块作用域与let和const

    ---恢复内容开始--- 在学习ES6的块作用域和 let.const 之前,我们先来看看ES5以前的 var 关键字. var 关键字用于定义一个变量,通常我们会将其与变量的赋值合并为一条语句,就像 ...

  3. vmware安装centos7

    VMware下安装CentOS7.2 http://www.mamicode.com/info-detail-1455647.html centos7.2配置网络 http://blog.csdn.n ...

  4. 中小研发团队架构实践之应用监控Metrics

    一.Metrics简介        应用监控系统Metrics由Metrics.NET+InfluxDB+Grafana组合而成,通过客户端Metrics.NET在业务代码中埋点,Metrics.N ...

  5. jq自定义多选下拉列表框

    多选选择国家插件 https://gitee.com/richard1015/dropDownList

  6. 【学习笔记】Hibernate HQL连接查询和数据批处理 (Y2-1-7)

    HQL连接查询 和SQL查询一样 hql也支持各种链接查询 如内连接 外连接 具体如下 左外连接 left (outer) join 迫切左外连接 left (outer) join fetch 右外 ...

  7. 关于 JS 拖拽功能的冲突问题及解决方法

    前言 我在之前写过关于 JS 拖拽的文章,实现方式和网上能搜到的方法大致相同,别无二致,但是在一次偶然的测试中发现,这种绑定事件的方式可能会和其它的拖拽事件产生冲突,由此产生了对于事件绑定的思考.本文 ...

  8. 机器学习之支持向量机(二):SMO算法

    注:关于支持向量机系列文章是借鉴大神的神作,加以自己的理解写成的:若对原作者有损请告知,我会及时处理.转载请标明来源. 序: 我在支持向量机系列中主要讲支持向量机的公式推导,第一部分讲到推出拉格朗日对 ...

  9. Android预定义样式

    字体大小 对于能够显示文字的控件(如TextView EditText RadioButton Button CheckBox Chronometer等等),你有时需要控制字体的大小.Android平 ...

  10. the c programing language 学习过程8

    glean 捡拾落穗; glean insight 深入了解 modeled模型化 peripheral外围的 himogeneous匀称的 intents 意图  excerpt摘录 intende ...