国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 威远县| 卢氏县| 安图县| 博客| 沽源县| 遂平县| 分宜县| 石渠县| 独山县| 顺昌县| 苏尼特左旗| 涞源县| 萝北县| 祁连县| 泰和县| 兴义市| 绥德县| 余庆县| 义马市| 时尚| 丰镇市| 巴东县| 汝州市| 建德市| 景宁| 双鸭山市| 运城市| 古蔺县| 新沂市| 青川县| 阿拉尔市| 南川市| 康乐县| 香港 | 新宾| 宝兴县| 雷州市| 宁海县| 姚安县| 上犹县| 富蕴县|