首页 > 代码库 > [HDOJ5734]Acperience(数学,公式推导)
[HDOJ5734]Acperience(数学,公式推导)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5734
1 /* 2 ━━━━━┒ギリギリ♂ eye! 3 ┓┏┓┏┓┃キリキリ♂ mind! 4 ┛┗┛┗┛┃\○/ 5 ┓┏┓┏┓┃ / 6 ┛┗┛┗┛┃ノ) 7 ┓┏┓┏┓┃ 8 ┛┗┛┗┛┃ 9 ┓┏┓┏┓┃10 ┛┗┛┗┛┃11 ┓┏┓┏┓┃12 ┛┗┛┗┛┃13 ┓┏┓┏┓┃14 ┃┃┃┃┃┃15 ┻┻┻┻┻┻16 */17 #include <algorithm>18 #include <iostream>19 #include <iomanip>20 #include <cstring>21 #include <climits>22 #include <complex>23 #include <fstream>24 #include <cassert>25 #include <cstdio>26 #include <bitset>27 #include <vector>28 #include <deque>29 #include <queue>30 #include <stack>31 #include <ctime>32 #include <set>33 #include <map>34 #include <cmath>35 using namespace std;36 #define fr first37 #define sc second38 #define cl clear39 #define BUG puts("here!!!")40 #define W(a) while(a--)41 #define pb(a) push_back(a)42 #define Rint(a) scanf("%d", &a)43 #define Rs(a) scanf("%s", a)44 #define Cin(a) cin >> a45 #define FRead() freopen("in", "r", stdin)46 #define FWrite() freopen("out", "w", stdout)47 #define Rep(i, len) for(int i = 0; i < (len); i++)48 #define For(i, a, len) for(int i = (a); i < (len); i++)49 #define Cls(a) memset((a), 0, sizeof(a))50 #define Clr(a, x) memset((a), (x), sizeof(a))51 #define Full(a) memset((a), 0x7f7f7f, sizeof(a))52 #define lrt rt << 153 #define rrt rt << 1 | 154 #define pi 3.1415926535955 #define RT return56 #define lowbit(x) x & (-x)57 #define onecnt(x) __builtin_popcount(x)58 typedef long long LL;59 typedef long double LD;60 typedef unsigned long long ULL;61 typedef pair<int, int> pii;62 typedef pair<string, int> psi;63 typedef pair<LL, LL> pll;64 typedef map<string, int> msi;65 typedef vector<int> vi;66 typedef vector<LL> vl;67 typedef vector<vl> vvl;68 typedef vector<bool> vb;69 70 const int maxn = 100100;71 LL n;72 LL w, w2;73 LL K, B;74 75 LL gcd(LL x, LL y) {76 return y == 0 ? x : gcd(y, x%y);77 }78 79 int main() {80 // FRead();81 int T;82 Rint(T);83 W(T) {84 Rint(n);85 K = B = 0;86 For(i, 1, n+1) {87 cin >> w;88 w2 = w * w;89 B += abs(w);90 K += w2;91 }92 LL p = n * K - B * B;93 LL ex = gcd(p, n);94 cout << p/ex << "/" << n/ex << endl;95 }96 RT 0;97 }
[HDOJ5734]Acperience(数学,公式推导)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。