题目链接:http://poj.org/problem?id=2480

题目大意:

题解:

我一直很欣赏数学题完美的复杂度

#include<cstring>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll; const int N=(<<)+;
ll n;
int main()
{
//printf("%lld\n",phi(3));
while (scanf("%lld",&n)!=EOF)
{
ll ans=n;
for (ll i=;i*i<=n;i++)
{
if (n%i) continue;
//if (i==1) ans++;
ll j=;
while (n%i==) n/=i,j++;
ans/=i;
ans*=(i-)*j+i;
}
if (n>)
{
ans/=n;
ans*=*n-;
}
printf("%lld\n",ans);
}
return ;
}

[poj 2480] Longge's problem 解题报告 (欧拉函数)的更多相关文章

  1. 题解报告:poj 2480 Longge's problem(欧拉函数)

    Description Longge is good at mathematics and he likes to think about hard mathematical problems whi ...

  2. poj 2480 Longge's problem [ 欧拉函数 ]

    传送门 Longge's problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7327   Accepted: 2 ...

  3. POJ 2480 Longge's problem (积性函数,欧拉函数)

    题意:求∑gcd(i,n),1<=i<=n思路:f(n)=∑gcd(i,n),1<=i<=n可以知道,其实f(n)=sum(p*φ(n/p)),其中p是n的因子.为什么呢?原因 ...

  4. poj 2480 Longge's problem

    /** 大意: 计算f(n) = ∑ gcd(i, N) 1<=i <=N. 思路: gcd(i,x*y) = gcd(i,x) * gcd(i, y ) 所以gcd 为积性函数 又因为积 ...

  5. POJ 3090 Visible Lattice Points | 其实是欧拉函数

    题目: 给一个n,n的网格,点可以遮挡视线,问从0,0看能看到多少点 题解: 根据对称性,我们可以把网格按y=x为对称轴划分成两半,求一半的就可以了,可以想到的是应该每种斜率只能看到一个点 因为斜率表 ...

  6. 【SDOI2012】Longge 的问题 题解(欧拉函数)

    前言:还算比较简单的数学题,我这种数学蒟蒻也会做QAQ. --------------- 题意:求$\sum\limits_{i=1}^n gcd(i,n)$的值. 设$gcd(i,n)=d$,即$d ...

  7. POJ 2480 Longge's problem 欧拉函数—————∑gcd(i, N) 1<=i <=N

    Longge's problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6383   Accepted: 2043 ...

  8. poj 2480 Longge's problem 欧拉函数+素数打表

    Longge's problem   Description Longge is good at mathematics and he likes to think about hard mathem ...

  9. 【poj 2478】Farey Sequence(数论--欧拉函数 找规律求前缀和)

    题意:定义 Fn 序列表示一串 <1 的分数,分数为最简分数,且分母 ≤n .问该序列的个数.(2≤N≤10^6) 解法:先暴力找规律(代码见屏蔽处),发现 Fn 序列的个数就是 Φ(1)~Φ( ...

随机推荐

  1. java.util.UnknownFormatConversionException: Conversion = ''';

    今天在测试一个新的项目,在执行sql查询报表的时候.由于我的sql中带有%,导致在输出日志时报错“java.util.UnknownFormatConversionException: Convers ...

  2. LeetCode104_MaximumDepthofBinaryTree Java题解

    题目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the ...

  3. [Hyperapp] Interact with the State Object through Hyperapp Action functions

    Hyperapp is an ultra lightweight (1kb), minimal, functional, JavaScript library for building UIs. It ...

  4. Vitual Router in The Cloud

    VyOS and ESXi,VyOS Configuration The next step is to configure both VyOS routers. Before we do, we s ...

  5. 文件类似性推断 -- SimHash

    近期调研了一下simhash算法,它主要用在谷歌网页去重中.网上有非常多原理性的介绍. 既然能够用来推断文件的相似性,就想知道效果怎么样.simhash的准确度是否依赖于分词算法?是否和simhash ...

  6. oracle 11g not in 与not exists 那个高效?

    网络上很多谣言是后面跟小表用not in,后面跟大表用not exists,难道真的是这样子的嘛? 情况下面测试: 1.先用小表测试(1000条记录和一张8万条记录的表): SQL> creat ...

  7. Spannable对textview首行缩进的设置

    1.创建Spannable对象 SpannableString contentSpan = new SpannableString(data.getBusinessTitle()); 2.设置文本缩进 ...

  8. OpenGL编程(七)3D模型的深度(z轴)检测

    下图是我们要修改后的效果图: 一.深度检测 1.模型Z轴显示有问题: 上一次试验中,如果认真留意,会发现一个问题.当控制锥体在左右或上下旋转时,你会发现锥体看起来是在+-180度之间来回摆动,而不是3 ...

  9. mybatis批量插入、批量更新和批量删除

    转载 https://www.jianshu.com/p/041bec8ae6d3

  10. HCF4094(CD4094)应用

    管脚说明和内部逻辑图 注:管脚图为HCF4094,内部逻辑图为CD4094(HCF4094内部逻辑图在datasheet不清晰,且复杂). 其中控制管脚有3个:STROBE-DATA-CLOCK,Ou ...