博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu5734——Acperience(数学推导)
阅读量:2343 次
发布时间:2019-05-10

本文共 2502 字,大约阅读时间需要 8 分钟。

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 . Professor Zhang would like to find a binary vector and a scaling factor in such a manner that is minimum.

Note that denotes the Euclidean norm (i.e. , where ).

Input

There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integers – the length of the vector. The next line contains integers: .

Output

For each test case, output the minimum value of as an irreducible fraction “/” where , are integers, .

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 
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 1010#define mod 1000000007using namespace std;long long gcd(long long a,long long b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ int t,n; scanf("%d",&t); while(t--) { long long sum1=0,sum2=0,w; scanf("%d",&n); for(int i=1;i<=n;++i) { scanf("%I64d",&w); sum1+=abs(w); sum2+=(w*w); } long long a=n*sum2-(sum1*sum1); long long b=n; long long c=gcd(a,b); long long aa=a/c,bb=b/c; printf("%I64d/%I64d\n",aa,bb); } return 0;}
你可能感兴趣的文章
I2C死锁原因及解决方法【转】
查看>>
Ubuntu系统如何安装双网卡及更改网卡名称(eth0改为eth1)
查看>>
二维数组指针
查看>>
Linux下socket的五种IO模型
查看>>
1--ip首部
查看>>
2--第四层
查看>>
3--TCP三次握手
查看>>
4--网关
查看>>
4.内存非连续分配管理方式
查看>>
5.虚拟内存的概念、特征以及虚拟内存的实现
查看>>
mmap()函数:建立内存映射
查看>>
munmap()函数:解除内存映射
查看>>
三层交换机是否会代替路由器?
查看>>
5--TCP的状态
查看>>
6--企业常用防火墙iptables相关原理详解
查看>>
7--企业常用防火墙iptables核心配置讲解
查看>>
1.block_inode
查看>>
2.Linux文件和目录之间对应关系
查看>>
4.硬链接和软链接
查看>>
线性表的长度为10,在最坏情况下,冒泡排序需要比较次数为()----腾讯2016研发工程师在线模拟笔试题
查看>>