POJ3090 Visible Lattice Points
/*
* POJ3090 Visible Lattice Points
* 欧拉函数
*/
#include<cstdio>
using namespace std;
int C,N;
//欧拉函数模板
int Euler(int n) {
int num = n;
for(int i = 2;i <= n;i++) {
if(n % i == 0) {
num = num / i * (i-1);
}
while(n % i == 0) {
n /= i;
}
}
return num;
}
int solve(int n) {
int sum = 0;
if(n == 1)
return 3;
sum = solve(n-1);
sum += 2*Euler(n);
return sum;
}
int main() {
scanf("%d",&C);
for(int i = 1;i <= C;i++) {
scanf("%d",&N);
printf("%d %d %d\n",i,N,solve(N));
}
return 0;
}
POJ3090 Visible Lattice Points的更多相关文章
- ACM学习历程—POJ3090 Visible Lattice Points(容斥原理 || 莫比乌斯)
Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal ...
- POJ3090 Visible Lattice Points 欧拉函数
欧拉函数裸题,直接欧拉函数值乘二加一就行了.具体证明略,反正很简单. 题干: Description A lattice point (x, y) in the first quadrant (x a ...
- POJ3090 Visible Lattice Points (数论:欧拉函数模板)
题目链接:传送门 思路: 所有gcd(x, y) = 1的数对都满足题意,然后还有(1, 0) 和 (0, 1). #include <iostream> #include <cst ...
- [POJ3090]Visible Lattice Points(欧拉函数)
答案为3+2*∑φ(i),(i=2 to n) Code #include <cstdio> int T,n,A[1010]; void Init(){ for(int i=2;i< ...
- POJ3090 Visible Lattice Points 欧拉筛
题目大意:给出范围为(0, 0)到(n, n)的整点,你站在原点处,问有多少个整点可见. 线y=x和坐标轴上的点都被(1,0)(0,1)(1,1)挡住了.除这三个钉子外,如果一个点(x,y)不互质,则 ...
- 数论 - 欧拉函数的运用 --- 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 ...
随机推荐
- Date类型与字符串之间的转换
Java中Date类型与字符串转化 (一)Date与字符串的转化 Date.String.Timestamp之间的转换! public static void main(String[] ...
- PHP版本MS17-010检测小脚本
内网渗透的时候有点用处,可以检测MS17-010的漏洞并获取操作系统信息,配合BURP可批量检测,纯socket发包,无需其他扩展. <?php //根据巡风python代码翻译成PHP代码 / ...
- STL next_permutation 算法原理和自行实现
目标 STL中的next_permutation 函数和 prev_permutation 两个函数提供了对于一个特定排列P,求出其后一个排列P+1和前一个排列P-1的功能. 这里我们以next_pe ...
- 山东13年省赛 Aliceand Bob
Problem F: Alice and Bob Description Alice and Bob like playing games very much.Today, they introduc ...
- 【RabbitMQ】工作模式介绍
一.前言 之前,笔者写过< CentOS 7.2 安装 RabbitMQ> 这篇文章,今天整理一下 RabbitMQ 相关的笔记便于以后复习. 二.模式介绍 在 RabbitMQ 官网上提 ...
- jQuery设置时间格式
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- [redis] redis
redis是什么? wiki redis官方介绍:introduction to redis 安装: install 拉到最下面的install小节 wget http://download.redi ...
- java学习笔记-集合set
equals指内容(值)相等,== 指地址相等 ===============set类 set继承自collection,但set没有新增方法,只是set里的元素不重复,下面是set常用方法 ==== ...
- Postman 快速入门之脚本
1.学习中心,官方文档 https://learning.getpostman.com/docs/postman/scripts/test_scripts/ 2.基于Postman的API自动化测试 ...
- jquery实现一个标签图标hover到上面的时候显示tooltip
设计图: 解决思路:1.在thumbnailbox.js这个插件中加入tags弹出框显示的内容,一开始让这些内容display:none; 然后再用css画出来一个三角形 实现方法: 知识点:Jque ...