答案为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. July 13th 2017 Week 28th Thursday

    No dream is too big, and no dreamer is too small. 梦想再大也不嫌大,追梦的人再小也不嫌小. Hold on to your dreams, but b ...

  2. 关于LDA的文章

    转:http://www.zhizhihu.com/html/y2011/3228.html l  Theory n  Introduction u  Unsupervised learning by ...

  3. WAS8.5安装和部署

    刚研究WAS8.5的安装部署,写一些注意事项: 1.下载安装软件 安装器:agent.installer.linux.gtk.x86_64_1.7.2000.20140227_0303 WAS: WA ...

  4. Spring Framework5.0 学习(1)—— 用Gradle构建一个Java Project

    1.0  安装Gradle,参考之前文章<Gradle入门实战(Windows版)> 2.0  使用gradle 快速生成一个Java project gradle init --type ...

  5. bzoj4600 [Sdoi2016]硬币游戏

    Description Alice和Bob现在在玩的游戏,主角是依次编号为1到n的n枚硬币.每一枚硬币都有两面,我们分别称之为正面和反面.一开始的时候,有些硬币是正面向上的,有些是反面朝上的.Alic ...

  6. BZOJ1924:[SDOI2010]所驼门王的宝藏(强连通分量,拓扑排序)

    Description Input 第一行给出三个正整数 N, R, C. 以下 N 行,每行给出一扇传送门的信息,包含三个正整数xi, yi, Ti,表示该传送门设在位于第 xi行第yi列的藏宝宫室 ...

  7. viewsate用法

    ViewState["名称"]="ssss";直接赋值取值只能在同一个页面使用, 离开页面就会失效

  8. wordpress上传含中文文件名出现乱码

    一.首先到FTP里面找到wp-admin/includes/file.php这个文件. 二.查找wp_handle_upload在文件里面找到以下代码. function wp_handle_uplo ...

  9. 用cookie实现记住用户名和密码

    1.当第一次发送请求时,在jsp页面并不能获取cookie对象,第一次是addCookie,之后再请求时才能获得. session和sessionid在服务器端生成的时候,同时把sessionID放在 ...

  10. Flex入坑指南

    弹性布局flex是一个几年前的CSS属性了,说它解放了一部分生产力不为过.至少解放了不少CSS布局相关的面试题 :) 之前网上流行的各种XX布局,什么postion: absolute+margin, ...