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. Windows Azure Virtual Network (11) 虚拟网络之间点对点连接VNet Peering

    <Windows Azure Platform 系列文章目录> 在有些时候,我们需要通过VNet Peering,把两个虚拟网络通过内网互通互联.比如: 1.在订阅A里的Virtual N ...

  2. Java数据结构和算法(九)——高级排序

    春晚好看吗?不存在的!!! 在Java数据结构和算法(三)——冒泡.选择.插入排序算法中我们介绍了三种简单的排序算法,它们的时间复杂度大O表示法都是O(N2),如果数据量少,我们还能忍受,但是数据量大 ...

  3. Windows下快速建立cocos2d-x项目

    准备工作     1.根据当前系统版本,下载对应版本的Python         32位下载地址:http://www.python.org/ftp/python/2.7.5/python-2.7. ...

  4. 较复杂makefile跟lds脚本程序的编写

    首先看个makefile范例: /*指明工具链,并为其取个简单的别名*/ CC = arm-linux-gcc LD = arm-linux-ld AR = arm-linux-ar OBJCOPY ...

  5. Javascript Sting(字符串)对象

    一, 如何计算字符串的长度? 可以通过.length属性来计算 <script type="text/javascript"> var txt="Hello ...

  6. php分布式redis实现session共享

    方法一:找到配置文件php.ini,修改为下面内容,保存并重启服务 session.save_handler = redis session.save_path = "tcp://127.0 ...

  7. mac下自带的Apache+PHP环境输出错误提示

    sudo vim /etc/php.ini 找到 display_errors = Off ,把Off 改为 On . 最后为 display_errors = On ; 找到 error_repor ...

  8. angular2-qrcode (转)

    插件选择 angular2-qrcode npm install angular2-qrcode --savecnpm install angular2-qrcode --save 参考github ...

  9. mybatis自动生成mapper,dao映射文件

    利用Mybatis-Generator来帮我们自动生成mapper.xml文件,dao文件,model文件. 1.所需文件 关于Mybatis-Generator的下载可以到这个地址:https:// ...

  10. IE兼容swiper

    swiper3能完美运用在移动端,但是运用在PC端,特别是IE浏览器上不能兼容,没有效果,要使IE兼容Swiper的话必须使用swiper2,也就是idangerous.swiper.js, 下载地址 ...