就欧拉函数然后地推一下。

#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的更多相关文章

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

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

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

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

  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 莫比乌斯,分块

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

  5. P8 Visible Lattice Points

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

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

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

  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. Spring使用mutipartFile上传文件报错【Failed to instantiate [org.springframework.web.multipart.MultipartFile]】

    报错场景: 使用SSM框架实现文件上传时报“Failed to instantiate [org.springframework.web.multipart.MultipartFile]”错,控制器源 ...

  2. K-均值聚类——电影类型

    K-均值聚类 K-均值算法试图将一系列样本分割成K个不同的类簇(其中K是模型的输入参数),其形式化的目标函数称为类簇内的方差和(within cluster sum of squared errors ...

  3. 真是shi

    降雨量那题,真踏马shi. 调到还有五个RE不调了. 开始以为map可水后来发现一定要二分查找一下. 这种题没啥营养,不过我发现了我ST表一处错误并打了个板子.就这点用处吧. 这几天做题太少了,每天不 ...

  4. FileStream流媒体

    class Program { static void Main(string[] args) { string source = @"mana.mp4"; string targ ...

  5. 嵌入式(Embedded System)笔记 —— Cortex-M3 Introduction and Basics(下)

    随着课内的学习,我想把每节课所学记录下来,以作查阅.以饲读者.由于我所上的是英文班课程,因此我将把关键术语的英文给出,甚至有些内容直接使用英文. 本次所介绍内容仍是关于Cortex-M3的基础内容,相 ...

  6. 《数据结构》C++代码 堆(优先队列)

    堆,是优先队列最常用的一种实现方式.在优先队列中,每个元素都被赋予了一个优先级,而每次出队时都让优先级最高的元素出队.堆,则是一种存储优先队列的方法,特指以一棵树形式存储的优先队列.最常用的是二叉堆, ...

  7. 【Text Justification】cpp

    题目: Given an array of words and a length L, format the text such that each line has exactly L charac ...

  8. WPF 利用键盘钩子来捕获键盘,做一些不为人知的事情...完整实例

    键盘钩子是一种可以监控键盘操作的指令. 看到这句话是不是觉得其实键盘钩子可以做很多事情. 场景 当你的程序需要一个全局的快捷键时,可以考虑使用键盘钩子,如大家常用qq的截图快捷键,那么在WPF里怎么去 ...

  9. ADB命令总结(1)

    今日继续学习ADB,使用真机来操作,因此把所用到的命令总结如下: 一,模拟按HOME键 adb shell input keyevent KEYCODE_HOME 二,滑动手机屏幕 从(x1,y1)滑 ...

  10. 洛谷P1003铺地毯(提高组)

    题目描述 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯.一共有 n 张地毯,编号从 1 到n. 现在将这些地毯按照编号从小到大的顺序平行于 ...