UVALIVE 3571 Visible Lattice Points
就欧拉函数然后地推一下。
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
int phi[];
int ans[];
void calcu()
{
memset(phi,,sizeof(phi));
phi[] = ;
for (int i = ; i <= ; i++)
if (!phi[i])
for (int j = i; j <= ; j += i)
{
if (!phi[j]) phi[j] = j;
phi[j] = phi[j] / i * (i - );
}
ans[] = ;
ans[] = ;
for (int i = ; i <= ; i++)
ans[i] = ans[i - ] + phi[i] * ;
}
int main()
{
int kase = ;
int T;
calcu();
scanf("%d",&T);
while (T--)
{
int n;
scanf("%d",&n);
printf("%d %d %d\n",kase++,n,ans[n]);
}
return ;
}
UVALIVE 3571 Visible Lattice Points的更多相关文章
- 数论 - 欧拉函数的运用 --- poj 3090 : Visible Lattice Points
Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5636 Accepted: ...
- spoj 7001. Visible Lattice Points GCD问题 莫比乌斯反演
SPOJ Problem Set (classical) 7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N la ...
- poj 3060 Visible Lattice Points
http://poj.org/problem?id=3090 Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Tota ...
- Spoj 7001 Visible Lattice Points 莫比乌斯,分块
题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=37193 Visible Lattice Points Time L ...
- P8 Visible Lattice Points
P8 Visible Lattice Points Time Limit:1000ms, Memory Limit:65536KB Description A lattice point (x ...
- 【POJ】3090 Visible Lattice Points(欧拉函数)
Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7705 Accepted: ...
- POJ3090 Visible Lattice Points
/* * POJ3090 Visible Lattice Points * 欧拉函数 */ #include<cstdio> using namespace std; int C,N; / ...
- Visible Lattice Points (莫比乌斯反演)
Visible Lattice Points 题意 : 从(0,0,0)出发在(N,N,N)范围内有多少条不从重合的直线:我们只要求gcd(x,y,z) = 1; 的点有多少个就可以了: 比如 : 点 ...
- 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 ...
随机推荐
- P2158 [SDOI2008]仪仗队 欧拉函数模板
题目描述 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是否整齐(如下图 ...
- 笔记-Python-language reference-5.the import system
笔记-Python-language reference-5.the import system 前言 经常用到import,module,对其中的机制及原理有一定的了解,但没有将各种信息前后连通起来 ...
- JVM——参数设置、分析
原文:http://www.cnblogs.com/redcreen/archive/2011/05/04/2037057.html 不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断 ...
- PHP.35-TP框架商城应用实例-后台11-商品分类-删除分类(2种方法)、添加、修改
删除分类 删除一个分类的同时,其所有子分类都删除 在控制器CategoryCtroller.class.php中添加删除函数(delete) 在分类模型中添加钩子函数_before_delete()[ ...
- 14,flask-sqlalchemy项目配置
基于一个flask项目,加入flask-SQLAlchemy 1.加入falsk-sqlalchemy第三方组件 from flask import Flask # 导入Flask-SQLAlchem ...
- 3714: [PA2014]Kuglarz
3714: [PA2014]Kuglarz 链接 思路: 好题.对于每个点都需要确定它的值,那么一个点可以直接询问[i,i]来确定,或者已经知道了[i,j]和[i+1,j]推出来. 但是可能产生冲突, ...
- Java的接口和抽象类深入理解
对于面向对象编程来说,抽象是它的一大特征之一.在Java中,可以通过两种形式来体现OOP的抽象:接口和抽象类.这两者确实有很多相似的地方,看了一整天别人怎么说,大致总结如下: 一.抽象类 在了解抽象类 ...
- 新工具填补Docker管理空白
[TechTarget中国原创] 从事容器管理领域的IT运维专家这周需要评估一个新的工具. Docker推出了一款新产品,意在让IT运维人员能够跟上开发人员的脚步,这一产品是Docker Datace ...
- Unicode字符图标
http://unicode-table.com/cn/#control-character
- Windows下如何解决git bash的默认home目录路径问题
转自:http://blog.csdn.net/lucien_zhou/article/details/62069246 为了解决这个问题,我在网上找了好久,尝试过按网上其他人所述,修改 git 安装 ...