HDU 4981 Goffi and Median】的更多相关文章

HDU 4981 Goffi and Median 思路:排序就能够得到中间数.然后总和和中间数*n比較一下就可以 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int N = 1005; int n, a[N], sum; int main() { while (~scanf("%d…
题解:排序取中位数,然后与平均数比较即可. #include <cstdio> #include <algorithm> using namespace std; double a[1005],ave,med,sum; int n; int main(){ while(~scanf("%d",&n)){ sum=0; for(int i=1;i<=n;i++){scanf("%lf",&a[i]);sum+=a[i];}…
HDU 4982 Goffi and Squary Partition 思路:直接从全然平方数往下找,然后推断是否能构造出该全然平方数,假设能够就是yes,假设都不行就是no.注意构造时候的推断,因为枚举一个全然平方数.剩下数字为kk.构造的时候要保证数字不反复 代码: #include <cstdio> #include <cstring> #include <cmath> int n, k; bool judge(int num) { int yu = num *…
题目链接:hdu 4983 Goffi and GCD 题目大意:求有多少对元组满足题目中的公式. 解题思路: n = 1或者k=2时:答案为1 k > 2时:答案为0(n≠1) k = 1时:须要计算,枚举n的因子.令因子k=gcd(n−a,n, 那么还有一边的gcd(n−b,n)=nk才干满足相乘等n.满足k=gcd(n−a,n)的a的个数即为ϕ(n/s),欧拉有o(n‾‾√的算法 #include <cstdio> #include <cstring> #include…
HDU 4983 Goffi and GCD 思路:数论题.假设k为2和n为1.那么仅仅可能1种.其它的k > 2就是0种,那么事实上仅仅要考虑k = 1的情况了.k = 1的时候,枚举n的因子,然后等于求该因子满足的个数,那么gcd(x, n) = 该因子的个数为phi(n / 该因子),然后再利用乘法原理计算就可以 代码: #include <cstdio> #include <cstring> #include <cmath> typedef long lo…
Goffi and Squary Partition Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Recently, Goffi is interested in squary partition of integers. A set X of k distinct positive i…
Problem Description Goffi is doing his math homework and he finds an equality on his text book: gcd(n−a,n)×gcd(n−b,n)=nk. Goffi wants to know the number of (a,b) satisfy the equality, if n and k are given and 1≤a,b≤n. Note: gcd(a,b) means greatest co…
题目大意:给你N和K,问有多少个数对满足gcd(N-A,N)*gcd(N-B,N)=N^K.题解:由于 gcd(a, N) <= N,于是 K>2 都是无解,K=2 只有一个解 A=B=N,只要考虑K=1的情况就好了其实上式和这个是等价的gcd(A,N)*gcd(B,N)=N^K,我们枚举gcd(A,N)=g,那么gcd(B,N)=N/g.问题转化为统计满足 gcd(A, N)=g的A的个数.这个答案就是 ɸ(N/g),只要枚举 N 的 约数就可以了.答案是 Σɸ(N/g)*ɸ(g)(g|N)…
中位数是否大于平均数 水题 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <queue> #include <map> #include <iostream> #include <algorithm> using namespace std; #d…
HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsum  贪心 HDU 1004 Let the Balloon Rise  字典树,map HDU 1005 Number Sequence  求数列循环节 HDU 1007 Quoit Design  最近点对 HDU 1008 Elevator  模拟 HDU 1010 Tempter of th…