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. 洛谷 [P2590] 树的统计

    迷之TLE #include <iostream> #include <cstdio> #include <cstring> #include <algori ...

  2. 一、爬虫的基本体系和urllib的基本使用

    爬虫 网络是一爬虫种自动获取网页内容的程序,是搜索引擎的重要组成部分.网络爬虫为搜索引擎从万维网下载网页.一般分为传统爬虫和聚焦爬虫. 爬虫的分类 传统爬虫从一个或若干初始网页的URL开始,获得初始网 ...

  3. 使用ssh 登录Linux 文件上传下载方法

    最简单的方法: 安装WinSCP或者Filezilla, 启动该程序,然后自己输入输入主机名.端口.用户名.密码登录,然后在putty里面用pwd命令看看当前目录,再在WinSCP/Filezilla ...

  4. Hive metastore整体代码分析及详解

    从上一篇对Hive metastore表结构的简要分析中,我再根据数据设计的实体对象,再进行整个代码结构的总结.那么我们先打开metadata的目录,其目录结构: 可以看到,整个hivemeta的目录 ...

  5. 音乐之声——midi制作原理

    实际发出声音需要4项必备的条件 1 发生的装置 Sequencer     把sequencer想成CD播放机 (plays) 2 要演奏的乐曲 Sequence     sequence就好像是单曲 ...

  6. 12小时格式Xcode的-在一个“TimePicker”24 NSDate的设置

    我正在使用的NSDate对象,和好了,我的iPhone与24小时格式,所以当我在测试我的应用程序,一切正常,但是,我的一个朋友试图在他的iPhone上的应用程序 CodeGo.net,但12小时格式, ...

  7. MySQL对sum()字段 进行条件筛选,使用having,不能用where

    显示每个地区的总人口数和总面积.仅显示那些面积超过1000000的地区. SELECT region, SUM(population), SUM(area) FROM bbc GROUP BY reg ...

  8. Java面试题库及答案解析

    1.面向对象编程(OOP)有哪些优点? 代码开发模块化,更易维护和修改. 代码复用. 增强代码的可靠性和灵活性. 增加代码的可理解性. 2.面向对象编程有哪些特性? 封装.继承.多态.抽象 封装 封装 ...

  9. MySQL数据库基础(一)(启动/停止、登录/退出、语法规范及最基础操作)

    1.启动/停止MySQL服务 启动:net start mysql    停止:net stop mysql 2.MySQL登录/退出 登录:mysql 参数:如果连接的是本地服务器,一般用命令:my ...

  10. html2canvas在微信中无法使用

    html2canvas: https://github.com/niklasvh/html2canvas 本来想在微信网页中使用html2canvas生成图片,结果死活不行 测试发现在Chrome,手 ...