A lattice point (xy) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (xy) does not pass through any other lattice point. For example, the point (4, 2) is not visible since the line from the origin passes through (2, 1). The figure below shows the points (xy) with 0 ≤ xy ≤ 5 with lines from the origin to the visible points.

Write a program which, given a value for the size, N, computes the number of visible points (xy) with 0 ≤ xy ≤ N.

Input

The first line of input contains a single integer C (1 ≤ C ≤ 1000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing a single integer N (1 ≤ N ≤ 1000), which is the size.

Output

For each dataset, there is to be one line of output consisting of: the dataset number starting at 1, a single space, the size, a single space and the number of visible points for that size.

Sample Input

4
2
4
5
231

Sample Output

1 2 5
2 4 13
3 5 21
4 231 32549 思路:裸的欧拉函数,相当于求在第一象限有多少个不同斜率的点,k=y/x,当y与x互质时,其值唯一,直接打表求欧拉函数前缀和就行,y,x不同所以要乘2,y,x相同时未算,所以要加1
const int maxm = ;

int Euler[maxm];

void get_Euler() {
Euler[] = ;
for(int i = ; i <= maxm; ++i) {
if(!Euler[i]) {
for(int j = i; j <= maxm; j += i) {
if(!Euler[j]) Euler[j] = j;
Euler[j] = Euler[j] / i * (i-);
}
}
}
} int main() {
get_Euler();
for(int i = ; i <= maxm; ++i)
Euler[i] += Euler[i-];
int T, N;
scanf("%d", &T);
for(int i = ; i <= T; ++i) {
scanf("%d", &N);
printf("%d %d %d\n", i, N, * Euler[N] + );
}
return ;
}
												

Day7 - A - Visible Lattice Points POJ - 3090的更多相关文章

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

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

  2. 【POJ】3090 Visible Lattice Points(欧拉函数)

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

  3. poj 3060 Visible Lattice Points

    http://poj.org/problem?id=3090 Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Tota ...

  4. spoj 7001. Visible Lattice Points GCD问题 莫比乌斯反演

    SPOJ Problem Set (classical) 7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N la ...

  5. Spoj 7001 Visible Lattice Points 莫比乌斯,分块

    题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=37193   Visible Lattice Points Time L ...

  6. P8 Visible Lattice Points

    P8 Visible Lattice Points Time Limit:1000ms,     Memory Limit:65536KB Description A lattice point (x ...

  7. POJ3090 Visible Lattice Points

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

  8. Visible Lattice Points (莫比乌斯反演)

    Visible Lattice Points 题意 : 从(0,0,0)出发在(N,N,N)范围内有多少条不从重合的直线:我们只要求gcd(x,y,z) = 1; 的点有多少个就可以了: 比如 : 点 ...

  9. SPOJ1007 VLATTICE - Visible Lattice Points

    VLATTICE - Visible Lattice Points no tags  Consider a N*N*N lattice. One corner is at (0,0,0) and th ...

随机推荐

  1. idea 设置自定义注释

    详细:idea如何设置类头注释和方法注释 2016年10月13日 15:09:11 标签: idea / 注释 / 97989 编辑 删除 idea和eclipse的注释还是有一些差别的. idea: ...

  2. UIView动画的使用

    下面介绍三种简单的UIView动画的使用,如果在项目中对动画没有太多“细致化”的设计要求,基本够用了. 一.首尾式动画 说明:如果只是修改控件的属性,使用首尾式动画还是很方便的,如果还需要在动画完成后 ...

  3. cmd常用小命令

    #设置n秒后自动关机 -a取消 shutdown -s -t n #输出内容到fileName里,如果文件不存在将会创建文件,>是替换,>>是追加echo something > ...

  4. robot framework 接口post请求需要加headers

    说明:当你用RF进行post接口测试时候,那么需要加个headers=Content-Type=application/x-www-form-urlencoded,要不然会请求不成功的.

  5. 物联网协议CoAP协议学习

    CoAP:Constrained Application Protocol协议是为物联网中资源受限的设备制定的应用层协议,即简化版的基于UDP的HTTP协议.其核心内容为资源抽象.REST式交互可扩展 ...

  6. 页面渲染时js阻塞的解决方法

    一般地,一个包含外部样式表文件和外部脚本文件的HTML载入和渲染过程是这样的: 浏览器下载HTML文件并开始解析DOM. 遇到样式表文件link[rel=stylesheet]时,将其加入资源文件下载 ...

  7. 学习SpringMVC 文件上传 遇到的问题,403:returned a response status of 403 Forbidden ,409文件夹未找到

    问题一: 409:文件夹没有创建好,找不到指定的文件夹,创建了即可. 问题二: 403:returned a response status of 403 Forbidden 我出现这个错误的原因是因 ...

  8. 零基础学完Python的7大就业方向,哪个赚钱多?

    “ 我想学 Python,但是学完 Python 后都能干啥 ?” “ 现在学 Python,哪个方向最简单?哪个方向最吃香 ?” “ …… ” 相信不少 Python 的初学者,都会遇到上面的这些问 ...

  9. UniGUI之ServerModule常用设置(07)

    主要有两个设置,它是一个单独的, 这意味着它只在每个应用程序中创建一次. 它主要用于配置各种服务器设置.不能将组件放在ServerModule上. 如前所述, ServerModule 是一个单一的, ...

  10. 从POST和GET和request过滤掉SQL注入

    替换掉sql关键字,进行处理 // sql参数过滤 function sqlCheck($paramater){ $arr = array(); foreach($paramater as $k=&g ...