hdu-5734 Acperience(数学)
题目链接:
Acperience
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
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)).
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).
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=500+10;
const double eps=1e-6; int a[N],n;
LL sum=0,ans=0;
LL gcd(LL x,LL y)
{
if(y==0)return x;
return gcd(y,x%y);
}
int main()
{
int t;
read(t);
while(t--)
{
read(n);
sum=0,ans=0;
For(i,1,n)
{
read(a[i]);
sum=sum+(LL)a[i]*a[i];
if(a[i]<0)ans=ans-a[i];
else ans=ans+a[i];
}
LL x=(LL)n;
LL g=gcd(x*sum-ans*ans,x);
cout<<(x*sum-ans*ans)/g<<"/"<<x/g<<endl; }
return 0;
}
hdu-5734 Acperience(数学)的更多相关文章
- HDU 5734 Acperience(数学推导)
Problem Description Deep neural networks (DNN) have shown significant improvements in several applic ...
- HDU 5734 Acperience ( 数学公式推导、一元二次方程 )
题目链接 题意 : 给出 n 维向量 W.要你构造一个 n 维向量 B = ( b1.b2.b3 ..... ) ( bi ∈ { +1, -1 } ) .然后求出对于一个常数 α > 0 使得 ...
- HDU 5734 Acperience(返虚入浑)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5734 Acperience (推导)
Acperience 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...
- hdu 5734 Acperience 水题
Acperience 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...
- HDU 5734 Acperience
Acperience Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- hdu 5734 Acperience(2016多校第二场)
Acperience Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 5734 Acperience (公式推导) 2016杭电多校联合第二场
题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cs ...
- HDU 5734 A - Acperience
http://acm.hdu.edu.cn/showproblem.php?pid=5734 Problem Description Deep neural networks (DNN) have s ...
- Acperience HDU - 5734
Deep neural networks (DNN) have shown significant improvements in several application domains includ ...
随机推荐
- 算法之美--2.3.1 Z字形编排问题
2016-12-08 00:23:11 写在前面的话:万事贵在坚持,万事开头难,有很多的东西要学,要知道主次,讲究效率,大的方向对就行!坚持........ 一.图像压缩编码中的Z字排序 JPEG ...
- 赞一下TMS Software 和 AdvStringGrid
非常久前给Support发Email问能不能在设计期给AdvStringGrid标题加个数字标识.每次我都是自己改代码加上去.这次升级到新版本号,没想到增加了这个功能: 功能虽小可是非常有用,非常多的 ...
- python 工具 图片批量合并
注:代码两处设置 region = (4,3,x-3,y-5) 目的是crop剪去图片的白边,这个可以视情况改变 图片需要命名为 x_1.png .....这样的格式 #encoding=ut ...
- Unity Shaders and Effects Cookbook (3-4) 使用高光贴图
在学习完上一节之后.已经了解了在Unity 中怎样实现一个高光 Shader ,可是会有一个问题.就是效果看起来不切实际,如以下的问题 我用一张图片贴到了Cube上面.然后用了一个高光材质,得到了下图 ...
- Android记录24-WebView实现白天/夜间阅读模式
前言 本篇博客给大家分享一个WebView的使用案例.实现Android调用JavaScript代码来控制白天/夜间模式. 关于WebView怎样使用,官网有非常好的说明,Building Web A ...
- 关于Oracle中sysoper这个系统权限的问题
我们都知道Oracle数据库安装完之后.默认的会有这样几个系统角色或权限.nomal,sysdba,sysoper等等,之前每次登录Oracle的时候.都是直接以conn / as sysdba 的身 ...
- windown vs2012 编译ffplay
自己写的播放器播放有些文件出现问题,但ffplay播放都很正常,为方便调试,将ffplay.c编译成可执行文件. 一. 环境搭建 环境搭建前面已经有文章介绍,没有特殊的地方,不再赘述. 二.修改con ...
- MySQL 创始人:写代码比打游戏爽,程序员应多泡开源社区
王练 发布于2017年09月04日 收藏 43 开源中国全球专享福利,云栖大会购票大返现!>>> 根据StackOverflow的最新调查,MySQL仍然是全世界最流行的数 ...
- Core Data 版本号迁移经验总结
大家在学习和使用Core Data过程中,第一次进行版本号迁移的经历一定是记忆犹新,至少我是这种,XD.弄的不好,就会搞出一些因为迁移过程中数据模型出错导致的Crash.这里总结了一下Core Dat ...
- Create a /etc/yum.repos.d/mongodb-org-4.0.repo
Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux — MongoDB Manual https://doc ...