#include<iostream>
using namespace std;
//欧拉函数
int eular(int n){
int res=,i;
for(int i=;i*i<=n;i++){
if(n%i==){
n/=i;res*=i-;
while(n%i==){
n/=i;res*=i;
}
}
}
if(n>)
res*=n-;
return res;
}
int main(){
int n,m,sum;
cin>>n;
for(int i=;i<=n;i++){
sum=;
cin>>m;
for(int j=;j<=m;j++)
sum+=eular(j)*;//除(1,1)外,其余的点都有对称点
cout<<i<<" "<<m<<" "<<sum<<endl;
}
return ;
}

此题与Poj2407相似,不过有对称点需考虑。

我们仔细观察题目会发现符合条件的点的坐标x,y都是互质的,1与1互质这是个特例,因为它是唯一一个符合没有对称点的点,需特殊考虑,此外还有(0,1),(1,0)

两点,故sum起始为3,其余加上的是欧拉函数x2

poj3090--欧拉函数的更多相关文章

  1. poj3090欧拉函数求和

    E - (例题)欧拉函数求和 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     ...

  2. POJ3090 巧用欧拉函数 phi(x)

    POJ3090 给定一个坐标系范围 求不同的整数方向个数 分析: 除了三个特殊方向(y轴方向 x轴方向 (1,1)方向)其他方向的最小向量表示(x,y)必然互质 所以对欧拉函数前N项求和 乘2(关于( ...

  3. 欧拉函数,打表求欧拉函数poj3090

    欧拉函数 φ(n) 定义:[1,N]中与N互质的数的个数 //互质与欧拉函数 /* 求欧拉函数 按欧拉函数计算公式,只要分解质因数即可 */ int phi(int n){ int ans=n; ;i ...

  4. POJ3090(SummerTrainingDay04-M 欧拉函数)

    Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7450   Accepted: ...

  5. 算法复习——欧拉函数(poj3090)

    题目: Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or e ...

  6. POJ3090 Visible Lattice Points 欧拉函数

    欧拉函数裸题,直接欧拉函数值乘二加一就行了.具体证明略,反正很简单. 题干: Description A lattice point (x, y) in the first quadrant (x a ...

  7. hdu2588 GCD (欧拉函数)

    GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数.  (文末有题) 知 ...

  8. BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]

    2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 2553  Solved: 1565[Submit][ ...

  9. BZOJ 2818: Gcd [欧拉函数 质数 线性筛]【学习笔记】

    2818: Gcd Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 4436  Solved: 1957[Submit][Status][Discuss ...

  10. COGS2531. [HZOI 2016]函数的美 打表+欧拉函数

    题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...

随机推荐

  1. UVA 489-- Hangman Judge(暴力串处理)

     Hangman Judge  In ``Hangman Judge,'' you are to write a program that judges a series of Hangman gam ...

  2. 加濾鏡效果GlowTween

    /** * * new GlowTween(xxxx, 0xFFFF00); * new GlowTween(xxxx, 0x00FFFF); * GlowTween */ package com.r ...

  3. C# 中的委托和事件详解

    C# 中的委托和事件 文中代码在VS2005下通过,由于VS2003(.Net Framework 1.1)不支持隐式的委托变量,所以如果在一个接受委托类型的位置直接赋予方法名,在VS2003下会报错 ...

  4. 无废话MVC入门教程二[第一个小Demo]

    mvc技术交流,欢迎加群: 本文目标 1.了解"模型"."视图"."控制器"的创建.调试和使用过程. 本文目录 1.创建模型 2.创建视图 ...

  5. InitCommonControlsEx()

    参见:http://blog.sina.com.cn/s/blog_4fcd1ea30100qlzp.html MFC通用控件初始化 ********************************* ...

  6. eclipse 使用maven 创建springmvc + mybatis

    接着eclipse 使用maven 创建纯spring mvc项目 毕竟项目都要访问数据库的, 所以加上mybatis的支持也就是网上大多时候说的 SSM框架的搭建(Spring + Spring M ...

  7. Spring XML 不给提示

    a)window – preferences – myeclipse – xml – xml catalog b)User Specified Entries – add i. Location: D ...

  8. raspberrypi VNC server

    安装apt-get install tightvncserver tightvnc-java 启动vncserver -name vnc_raspi -depth 24 -geometry 800x6 ...

  9. java如何在一个有序的数组类插入一个数!

    第一种:依次与有序数组中的每个数进行比较,然后找到位置之后,定义一个新的数组,该信数组的长度加一,再使用system.arraycopy将于数组copy到新数组!import java.util.Ar ...

  10. CC EAL认证

    国际通用准则(CC) CC(Common Criteria)是国际标准化组织统一现有多种准则的结果,是目前最全面的评价准则.1996年6月,CC第一版发布:1998年5月,CC第二版发布:1999年 ...