poj3090--欧拉函数
#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--欧拉函数的更多相关文章
- poj3090欧拉函数求和
E - (例题)欧拉函数求和 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB ...
- POJ3090 巧用欧拉函数 phi(x)
POJ3090 给定一个坐标系范围 求不同的整数方向个数 分析: 除了三个特殊方向(y轴方向 x轴方向 (1,1)方向)其他方向的最小向量表示(x,y)必然互质 所以对欧拉函数前N项求和 乘2(关于( ...
- 欧拉函数,打表求欧拉函数poj3090
欧拉函数 φ(n) 定义:[1,N]中与N互质的数的个数 //互质与欧拉函数 /* 求欧拉函数 按欧拉函数计算公式,只要分解质因数即可 */ int phi(int n){ int ans=n; ;i ...
- POJ3090(SummerTrainingDay04-M 欧拉函数)
Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7450 Accepted: ...
- 算法复习——欧拉函数(poj3090)
题目: Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or e ...
- POJ3090 Visible Lattice Points 欧拉函数
欧拉函数裸题,直接欧拉函数值乘二加一就行了.具体证明略,反正很简单. 题干: Description A lattice point (x, y) in the first quadrant (x a ...
- hdu2588 GCD (欧拉函数)
GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数. (文末有题) 知 ...
- BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 2553 Solved: 1565[Submit][ ...
- BZOJ 2818: Gcd [欧拉函数 质数 线性筛]【学习笔记】
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 4436 Solved: 1957[Submit][Status][Discuss ...
- COGS2531. [HZOI 2016]函数的美 打表+欧拉函数
题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...
随机推荐
- UVA 489-- Hangman Judge(暴力串处理)
Hangman Judge In ``Hangman Judge,'' you are to write a program that judges a series of Hangman gam ...
- 加濾鏡效果GlowTween
/** * * new GlowTween(xxxx, 0xFFFF00); * new GlowTween(xxxx, 0x00FFFF); * GlowTween */ package com.r ...
- C# 中的委托和事件详解
C# 中的委托和事件 文中代码在VS2005下通过,由于VS2003(.Net Framework 1.1)不支持隐式的委托变量,所以如果在一个接受委托类型的位置直接赋予方法名,在VS2003下会报错 ...
- 无废话MVC入门教程二[第一个小Demo]
mvc技术交流,欢迎加群: 本文目标 1.了解"模型"."视图"."控制器"的创建.调试和使用过程. 本文目录 1.创建模型 2.创建视图 ...
- InitCommonControlsEx()
参见:http://blog.sina.com.cn/s/blog_4fcd1ea30100qlzp.html MFC通用控件初始化 ********************************* ...
- eclipse 使用maven 创建springmvc + mybatis
接着eclipse 使用maven 创建纯spring mvc项目 毕竟项目都要访问数据库的, 所以加上mybatis的支持也就是网上大多时候说的 SSM框架的搭建(Spring + Spring M ...
- Spring XML 不给提示
a)window – preferences – myeclipse – xml – xml catalog b)User Specified Entries – add i. Location: D ...
- raspberrypi VNC server
安装apt-get install tightvncserver tightvnc-java 启动vncserver -name vnc_raspi -depth 24 -geometry 800x6 ...
- java如何在一个有序的数组类插入一个数!
第一种:依次与有序数组中的每个数进行比较,然后找到位置之后,定义一个新的数组,该信数组的长度加一,再使用system.arraycopy将于数组copy到新数组!import java.util.Ar ...
- CC EAL认证
国际通用准则(CC) CC(Common Criteria)是国际标准化组织统一现有多种准则的结果,是目前最全面的评价准则.1996年6月,CC第一版发布:1998年5月,CC第二版发布:1999年 ...