hdu 5734 Acperience 2016 Multi-University Training Contest 2
2016-07-22 10:02
483 查看
Problem Description
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). Professor Zhang would like to find a binary vector B=(b1,b2,…,bn) (bi∈{+1,−1}) and a scaling factor α≥0 in such a manner that ∥W−αB∥2 is minimum.
Note that ∥⋅∥ denotes the Euclidean norm (i.e. ∥X∥=x21+⋯+x2n−−−−−−−−−−−√, where X=(x1,x2,…,xn)).
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integers n (1≤n≤100000) – the length of the vector. The next line contains n integers: w1,w2,…,wn (−10000≤wi≤10000).
Output
For each test case, output the minimum value of ∥W−αB∥2 as an irreducible fraction “p/q” where p, q are integers, q>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
这道题呢,需要推出公式,可以二元一次方程求最小值,也可以点到直线的距离,最终推出的公式为 wi的平方和减去wi的和的平方除以n;
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). Professor Zhang would like to find a binary vector B=(b1,b2,…,bn) (bi∈{+1,−1}) and a scaling factor α≥0 in such a manner that ∥W−αB∥2 is minimum.
Note that ∥⋅∥ denotes the Euclidean norm (i.e. ∥X∥=x21+⋯+x2n−−−−−−−−−−−√, where X=(x1,x2,…,xn)).
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integers n (1≤n≤100000) – the length of the vector. The next line contains n integers: w1,w2,…,wn (−10000≤wi≤10000).
Output
For each test case, output the minimum value of ∥W−αB∥2 as an irreducible fraction “p/q” where p, q are integers, q>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
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int i,t,n; long long w[100005],j; scanf("%d",&t); while(t--) { scanf("%d",&n); long long sum=0,sum1=0; for(i=0;i<n;i++) { scanf("%lld",&w[i]); sum+=fabs(w[i]); sum1+=w[i]*w[i]; } j=(n*sum1-sum*sum); long long a=j,b=n,v; while(n!=0) { v=j%n; j=n; n=v; } printf("%lld/%lld\n",a/j,b/j); } return 0; }
这道题呢,需要推出公式,可以二元一次方程求最小值,也可以点到直线的距离,最终推出的公式为 wi的平方和减去wi的和的平方除以n;
相关文章推荐
- v$session 视图中的 FAILOVER_TYPE 字段
- 2016 Multi-University Training Contest 2 It's All In The Mind
- 2016 Multi-University Training Contest 2 La Vie en rose
- 2016 Multi-University Training Contest 2 1001 Acperience
- failover机制
- 2016 Multi-University Training Contest 2----解题报告
- [Web 性能] repaint and reflow (重绘和回流)
- JAX-WS HandlerChain使用详解
- HDU5319 Painter【DFS】
- 2016 Multi-University Training Contest 2
- 最近的人工智能计算工作
- 人工智能计算
- LintCode_516 Paint House II
- LeetCode 172. Factorial Trailing Zeroes
- LeetCode 219. Contains Duplicate II
- Leetcode Contains Duplicate III
- CodeForces Gym 100646H You’ll be Working on the Railroad DFS
- git checkout Unlink of file try again
- ADK - SnowMountain场景制作(三)
- ADK - SnowMountain场景制作(二)