国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

[HDU]3501 Calculation 2 [歐拉函數之求和]

2019-11-08 03:04:54
字體:
來源:轉載
供稿:網友

PRoblem 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, there is a line containing a positive integer N(1 ≤ N ≤ 1000000000). A line containing a single 0 follows the last test case.

Output For each test case, you should print the sum module 1000000007 in a line.

Sample Input 3 4 0

Sample Output 0 2

解題報告

∑gcd(i,n)=1i<ni=n?φ(n)/2

#include<stdio.h>typedef __int64 LL;LL E(LL n){ LL res=1; for(LL i=2;i*i<=n;i++) if(n%i==0){ res*=i-1; n/=i; while(n%i==0) res*=i,n/=i; } if(n>1) res*=n-1; return res;}int main(){ LL n; while(~scanf("%lld",&n)&&n){ LL ans=(n-1)*n/2-n*E(n)/2; printf("%lld/n",ans%1000000007); } return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台安县| 遂川县| 永和县| 靖西县| 大兴区| 万山特区| 岑巩县| 连江县| 安徽省| 汉中市| 五台县| 泾川县| 石渠县| 南宁市| 丰顺县| 平度市| 佳木斯市| 荣昌县| 巨野县| 郸城县| 晋中市| 姜堰市| 都匀市| 揭东县| 延庆县| 丰台区| 松桃| 海城市| 道真| 宝丰县| 德庆县| 得荣县| 鄂托克旗| 宁武县| 江西省| 罗甸县| 札达县| 南皮县| 图片| 南皮县| 西安市|