HDU 5734 Acperience

Source: Internet
Author: User

Acperience

Time limit:4000/2000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): Accepted submission (s): 119


Problem Descriptiondeep Neural Networks (DNN) has 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), with demonstrated state-of-the -art results in object recognition and detection.

convolutional neural Networks show reliable results on object recognition and detection that is useful in real world appl Ications. Concurrent to the recent progress in recognition, interesting advancements has been happening in virtual reality (VR by O cULus), augmented Reality (AR by HoloLens), and smart wearable devices. Putting these-pieces together, we argue that it's the right time-to-equip smart portable devices with the power of St Ate-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 is often unsuitable for smaller devices like cell phones a nd embedded electronics.

In order to simplify the networks, Professor Zhang tries to introduce simple, efficient, and accurate approximations to CN Ns by binarizing the weights. Professor Zhang needs your help.

More specifically, given a weighted vector W =( w1,w2,..., WN).Professor Zhang would like to find a binary vector B =( b1,b2,..., bn)( b I∈{+1,-1})and a scaling factorα≥0In such a manner that | | WB || 2is minimum.

Note that||. || denotes the Euclidean norm (i.e.| | X|| =√ x12+...+Xn2, wher E x = (x 1,x2,..., xn).

Inputthere is multiple test cases. The first line of input contains an integerT, 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).

Outputfor each test case, output the minimum value of< Span id= "Mathjax-element-2-frame" class= "Mathjax" >| | W B | | 2 As an irreducible fraction " p/ q" where re integers, q >0.

Sample Input341 2 3 442 2 2 255 6 2 3 4

Sample OUTPUT5/10/110/1

Authorzimpha

Source2016 multi-university Training Contest 2 parsing:I=1?N??W?I?2??−?N??1??(?I=1?∑?N??∣w?i∣) ?2
1#include <bits/stdc++.h>2 3typedefLong Longll;4 5 ll GCD (ll A, ll b)6 {7     returnb = =0? A:GCD (b, a%b);8 }9 Ten intMain () One { A     intT, N; -scanf"%d", &T); -      while(t--){ thescanf"%d", &n); -ll w1 =0, W2 =0; -          for(inti =0, WI; I < n; ++i) { -scanf"%d", &WI); +W1 + = wi*WI; -W2 + =ABS (WI); +         } All a = w1*n-w2*w2, B =N; atll g =gcd (A, b); -printf"%i64d/%i64d\n", a/g, b/g); -     } -     return 0; -}

HDU 5734 Acperience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.