答案为3+2*∑φ(i),(i=2 to n)

Code

#include <cstdio>
int T,n,A[1010];
void Init(){
for(int i=2;i<=1000;++i)A[i]=i;
for(int i=2;i<=1000;++i)
if(A[i]==i)for(int j=i;j<=1000;j+=i)
A[j]=A[j]/i*(i-1);
for(int i=3;i<=1000;++i)A[i]+=A[i-1];
}
int main(){
Init(),scanf("%d",&T);
for(int i=1;i<=T;++i){
scanf("%d",&n);
printf("%d %d %d\n",i,n,3+2*A[n]);
}
return 0;
}

[POJ3090]Visible Lattice Points(欧拉函数)的更多相关文章

  1. POJ3090 Visible Lattice Points 欧拉函数

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

  2. POJ3090 Visible Lattice Points 欧拉筛

    题目大意:给出范围为(0, 0)到(n, n)的整点,你站在原点处,问有多少个整点可见. 线y=x和坐标轴上的点都被(1,0)(0,1)(1,1)挡住了.除这三个钉子外,如果一个点(x,y)不互质,则 ...

  3. POJ 3090 Visible Lattice Points 欧拉函数

    链接:http://poj.org/problem?id=3090 题意:在坐标系中,从横纵坐标 0 ≤ x, y ≤ N中的点中选择点,而且这些点与(0,0)的连点不经过其它的点. 思路:显而易见, ...

  4. [poj 3090]Visible Lattice Point[欧拉函数]

    找出N*N范围内可见格点的个数. 只考虑下半三角形区域,可以从可见格点的生成过程发现如下规律: 若横纵坐标c,r均从0开始标号,则 (c,r)为可见格点 <=>r与c互质 证明: 若r与c ...

  5. POJ3090 Visible Lattice Points

    /* * POJ3090 Visible Lattice Points * 欧拉函数 */ #include<cstdio> using namespace std; int C,N; / ...

  6. POJ3090 Visible Lattice Points (数论:欧拉函数模板)

    题目链接:传送门 思路: 所有gcd(x, y) = 1的数对都满足题意,然后还有(1, 0) 和 (0, 1). #include <iostream> #include <cst ...

  7. ACM学习历程—POJ3090 Visible Lattice Points(容斥原理 || 莫比乌斯)

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

  8. 数论 - 欧拉函数的运用 --- poj 3090 : Visible Lattice Points

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

  9. POJ_3090 Visible Lattice Points 【欧拉函数 + 递推】

    一.题目 A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), ...

随机推荐

  1. selenium借助send_keys实现上传(以网易邮箱为例)

    #code:utf-8from selenium import webdriverimport time#网易163邮箱dr = webdriver.Firefox()file_path = 'htt ...

  2. July 08th 2017 Week 27th Saturday

    You are never wrong to do the right thing. 坚持做对的事情,永远都不会错. I think the translation may be not precis ...

  3. vbox安装 ubuntu server 后 安装增强包

    用vbox安装虚拟机系统如果不装增强包, 有很多东西就有点不好用-用vbox安装ubuntu server时,点击菜单中的安装增强功能.因为ubuntu server版本没有ui,所以不能很方便滴找到 ...

  4. IOS ASI (第三方请求)

    什么是ASI全称是ASIHTTPRequest,外号“HTTP终结者”,功能十分强大基于底层的CFNetwork框架,运行效率很高可惜作者早已停止更新,有一些潜在的BUG无人去解决很多公司的旧项目里面 ...

  5. The Binder Architecture

    The Binder Architecture is a declarative architecture for iOS development inspired by MVVM and VIPER ...

  6. PHP------Jquery的用法

    Jquery Jquery实际上相当于一个升级版的JS,Jquery里面封装了很多的东西,Jquery的功能要比JS强大,用起来比JS方便.Jquery和JS都属于JS,只不过Jquery是封装了一个 ...

  7. CentOS gitlab 安装配置

    CentOS gitlab 安装配置 2018-11-02 11:23:09   Visit  5 在/etc/yum.repos.d 目录下创建文件gitlab-ce.repo,使用国内的安装源 b ...

  8. 【洛谷P1982】小朋友的数字

    小朋友的数字 题目链接 题目翻译: 每个小朋友有一个数字,构成一个数字序列a1,a2…an 我们定义“特征值”fi为a1~ai中的最大连续子段和 再定义“分数”si为1~i-1中最大的(sj+fj), ...

  9. 【luogu P3623 [APIO2008]免费道路】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3623 说是对克鲁斯卡尔的透彻性理解 正解: 先考虑加入水泥路,然后再考虑加入剩下必须要加入的最少鹅卵石路. ...

  10. hadoop-2.2.0 HA配置

    采用的是4台真实机器: namenode:qzhong  node27 datanode:qzhong node27 node100 node101 操作系统环境:qzhong(Ubuntu-14.0 ...