HDU 5734 Acperience 【数学计算】
来源:互联网 发布:抗衰老精华 知乎 编辑:程序博客网 时间:2024/06/10 18:37
官方题解非常好,难得的良心题解
#include <iostream>#include <ctime>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cstring>#include <vector>#include <map>#include <string>using namespace std;typedef long long LL;const int maxn = 100000 + 100;int n;const LL inf = 1LL<<60;LL a[maxn];LL LLabs(LL a){if (a<0)return -a;return a;}inline LL gcd(LL a,LL b){LL r;while(b>0){r=a%b;a=b;b=r;}return a;}void init(){scanf("%d", &n);for (int i = 1; i<=n;++i)scanf("%lld", &a[i]);}void doit(){LL tmp1=0, tmp2=0;for (int i = 1;i<=n;++i)tmp1 += a[i] * a[i];for (int i = 1; i<=n;++i)tmp2 += LLabs(a[i]);tmp2 = tmp2 * tmp2;tmp1 = n * tmp1 - tmp2;LL tmp3 = gcd(tmp1, n);tmp1 /= tmp3;n/=tmp3;printf("%lld/%lld\n", tmp1, n);}int main(){int T;scanf("%d", &T);while (T--){init();doit();}return 0;}
0 0
- HDU 5734 Acperience 【数学计算】
- hdu 5734 Acperience (数学)
- HDU 5734 Acperience (数学)
- HDU 5734 Acperience(数学推导【多校联合】)
- 化简-HDU-5734-Acperience
- hdu 5734 Acperience
- Hdu-5734 Acperience
- HDU 5734 Acperience
- HDU 5734 Acperience
- HDU 5734 - Acperience
- HDOJ 5734 Acperience (数学推导)
- HDU 5734 Acperience (观察)
- HDU 5734 Acperience(水~)
- HDU-5734 Acperience(公式化简)
- 2016 Multi-University Training Contest 2 hdu 5734 Acperience【推公式,数学】
- 数学——Acperience ( HDU 5734) ( 2016 Multi-University Training Contest 2 1001 )
- hdu 5734 Acperience(2016 Multi-University Training Contest 2——化简公式,数学推导)
- HDOJ 5734 Acperience(数学运算)
- jsp中简易版本的图片上传程序
- hdu 5791 dp
- POJ-2367 Genealogical tree 【拓扑模板题】
- HDU 3236 Gift Hunting dp 背包
- 设计模式经典书籍推荐
- HDU 5734 Acperience 【数学计算】
- CodeWars练习之打印菱形
- vim的常用命令
- dedecms 首页调用作者头像
- 恢复windows7的开始菜单栏的搜索框
- 二叉树的复制
- 2016多校联合训练赛 第三场1010 Rower Bo hdu 5761
- Oracle同义词创建及其作用
- 浅谈初识前端