HDU——T 3501 Calculation 2】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=3501 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4548    Accepted Submission(s): 1878 Problem Description Given a positive integer N, your task is t…
Calculation 2 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is s…
Calculation 2 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1750    Accepted Submission(s): 727 Problem Description Given a positive integer N, your task is to calculate the sum of the positiv…
题目链接 题意 : 求小于n的数中与n不互质的所有数字之和. 思路 : 欧拉函数求的是小于等于n的数中与n互质的数个数,这个题的话,先把所有的数字之和求出来,再减掉欧拉函数中所有质数之和(即为eular(n)*n/2),得到的就是最终结果,所以也是模板题一道. #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h&g…
题目 题意:求小于n并且 和n不互质的数的总和. 思路:求小于n并且与n互质的数的和为:n*phi[n]/2 . 若a和n互质,n-a必定也和n互质(a<n).也就是说num必定为偶数.其中互质的数成对存在.其和为n. 公式证明: 反证法:如果存在K!=1使gcd(n,n-i)=k,那么(n-i)%k==0而n%k=0那么必须保证i%k=0k是n的因子,如果i%k=0那么gcd(n,i)=k,矛盾出现; 所以先求出1……n-1 的和, 再用这个和 减去 上面公式求出来的值. 欧拉函数phi(m)…
题目大意:求小于n的与n不互质的数的和. 题解:首先欧拉函数可以求出小于n的与n互质的数的个数,然后我们可以发现这样一个性质,当x与n互质时,n-x与n互质,那么所有小于n与n互质的数总是可以两两配对使其和为n,这也就是为什么当n大于2时欧拉函数都是偶数,知道这一点后,就可以计算出小于n与n互质的数的和了,那么不互质的和只要用总和来减就可以了. #include <cstdio> typedef long long LL; LL n,ans; LL Eular(LL n){ LL ret=1;…
[题目分析] 卷积太有趣了. 最终得出结论,互质数和为n*phi(n)/2即可. 计算(n*(n+1)/2-n-n*phi(n)/2)%md,用反正法即可证明. [代码] #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <map> #include <set> #include <queue> #includ…
Description Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said to be coprime to B if A, B share no common positive divisors except 1. Input For each test case, ther…
感觉本题没有什么好解释的,已知公式,直接编程即可. 1.统计所有 科目的学分 得到总学分 2.统计所有 成绩对应的绩点*对应的学分即可(如果成绩==-1直接continue,不进行统计),得到总绩点. 3.如果总绩点<0 sorry -1,没有平均绩点 4. 总绩点/总学分 即可得到平均绩点 #include <stdio.h> int f(double x) { if(x>=90)return 4; else if(x>=80)return 3; else if(x>…
困难,.,真,,,不是太困难 的问题是,有一个矩阵运算优化 您有权发言权N*K矩阵A给K*N矩阵B(1<=N<=1000 && 1=<K<=6).他们拿起了第一次骑马C矩阵,再算上C^(N*N) 当于 ABABABABABABAB...=(AB)^(N*N) 不如 A(BA)^(N*N-1)B 由于BA乘得K*K的矩阵,K是比較小的 #include <cstdio> #include <cstdlib> #include <cstri…