题意:求一个正方体里面,有多少个顶点可以在(0,0,0)位置直接看到,而不被其它点阻挡。也就是说有多少个(x,y,z)组合,满足gcd(x,y,z)==1或有一个0,另外的两个未知数gcd为1

定义f(t)为gcd(x,y,z)==t或有一个0,另外的两个未知数gcd为t的组合数

定义F(x)为 ∑p(t)   x|t  =  (n/x)* (n/x) * (n/x+3)

那么满足下面的

求出f(1)即为答案

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1000000+10;
ll is[maxn],pri[maxn],u[maxn],cnt;
void getu()
{
u[1]=1;
for(int i=2;i<maxn;i++)
{
if(is[i]==0)
{
cnt++;
pri[cnt]=i;
u[i]=-1;
}
for(int j=1;j<=cnt;j++)
{
ll k=pri[j]*i;
if(k>=maxn)break;
is[k]=1;
if(i%pri[j]==0)u[k]=0;
else u[k]=-u[i];
}
}
}
int main()
{
getu();
// for(int i=1;i<=100;i++)
// cout<<i<<" "<<u[i]<<endl;
int T;
scanf("%d",&T);
while(T--)
{
ll n;
scanf("%lld",&n);
ll num=3;
for(int i=1;i<=n;i++)
num+=u[i]*(n/i)*(n/i)*(n/i+3);
printf("%lld\n",num);
}
return 0;
}

  

SPOJ 7001 Visible Lattice Points (莫比乌斯反演)的更多相关文章

  1. spoj 7001 Visible Lattice Points莫比乌斯反演

    Visible Lattice Points Time Limit:7000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Su ...

  2. SPOJ VLATTICE Visible Lattice Points (莫比乌斯反演基础题)

    Visible Lattice Points Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at ...

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

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

  4. SPOJ VLATTICE Visible Lattice Points 莫比乌斯反演 难度:3

    http://www.spoj.com/problems/VLATTICE/ 明显,当gcd(x,y,z)=k,k!=1时,(x,y,z)被(x/k,y/k,z/k)遮挡,所以这道题要求的是gcd(x ...

  5. SPOJ VLATTICE Visible Lattice Points 莫比乌斯反演

    这样的点分成三类 1 不含0,要求三个数的最大公约数为1 2 含一个0,两个非零数互质 3 含两个0,这样的数只有三个,可以讨论 针对 1情况 定义f[n]为所有满足三个数最大公约数为n的三元组数量 ...

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

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

  7. SPOJ 7001. Visible Lattice Points (莫比乌斯反演)

    7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N lattice. One corner is at (0,0, ...

  8. spoj7001 Visible Lattice Points 莫比乌斯反演+三维空间互质对数

    /** 题目:Visible Lattice Points 链接:https://vjudge.net/contest/178455#problem/A 题意:一个n*n*n大小的三维空间.一侧为(0 ...

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

    题目链接 /* http://www.spoj.com/problems/VLATTICE/ 题意:求一个n*n*n的晶体,有多少点可以在(0,0,0)处可以直接看到. 同BZOJ.2301 题目即要 ...

随机推荐

  1. 【苹果通知APNs】不知道大家用过PushSharp没?

    好久没写东西了,近期在研究Jenkins,大家有兴趣可以一起来玩玩交流,学习DevOps还是蛮重要. 近期我负责的项目里需要APNs的通知,这个自己单独开发还是蛮费功夫,故用了第三方开源的PushSh ...

  2. string[]转list<long>,List转字符串

    List转字符串,用逗号隔开 List<string> list = new List<string>();list.Add("a");list.Add(& ...

  3. js正则表达式 数字和小数点 非负数 保留两位小数点

    验证数字非负数  小数点保留两位小数点 下面正则已验证通过 /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/

  4. 【Vue 2.x】指令的学习

      v-on作用于事件,简写@ v-bind作用于html元素的属性,简写: v-for作用于模板内的变量,和C#的foreach类似的用法 v-if和v-show条件渲染html元素 v-model ...

  5. bootstrap-treeview 在 bootstrap 4 不兼容解决办法及使用

    bootstrap-treeview 是bootstrap的一个树形插件,插件依赖: bootstrap/3.3.7 jquery/3.3.1 经过验证,它不可以在 bootstrap 高于 3.3. ...

  6. mysql安装和配置(windowns||centos)

    windows10版本安装 1.获取mysql压缩包 https://dev.mysql.com/downloads/mysql/ 2.解压并配置文件my.ini .解压的文件路径 D:\Progra ...

  7. Linux 系统进程相关命令

    1.pstree  :可以使用pstree命令来查看系统中进程的分布结构. 2.ps: 常用于查看系统进程的命令是ps(process status)命令,可通过它来查看系统进程的最基本信息. ●-A ...

  8. zabbix3.4监控Linux客户端

    环境准备 zabbix-server IP:192.168.1.242 nds-server  IP:192.168.1.202 web-server IP:192.168.1.203 客户端部署 关 ...

  9. 黏包现象之TCP

    老师的博客:http://www.cnblogs.com/Eva-J/articles/8244551.html#_label5 server #_*_coding:gbk*_ from socket ...

  10. C#基础知识之类和结构体

    虽然项目中一直在使用类.结构体等类型,仔细琢磨,还真无法系统的说出个所以然.记录一下类.结构体.类和结构体区别 一.类 对于类,大家都特别熟悉.简单的介绍一下类的结构,然后记录一下Class需要注意的 ...