题意:求一个正方体里面,有多少个顶点可以在(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. Sql 语句拼接 多条件分页查询

    Create PROCEDURE [dbo].[Proc_B2B_GetBatchMainPaging] @StationNo AS varchar() , --m @StationName AS v ...

  2. 微信小程序组件minui在mac系统的使用注意事项

    1.mac系统使用npm 安装组件的时候,一定要注意mac系统的终端一定要用root用户操作. 具体的命令如下:sudo -i,然后提示输入系统的密码就进入了root操作用户. 2.然后就根据minu ...

  3. csharp: LocalDataCache.sync

    app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...

  4. RelativeLayout设置wrap_content无效

    尊重劳动成果,转载请标明出处:http://www.cnblogs.com/tangZH/p/8419053.html 在做项目的过程中,遇到了一个奇怪的现象,我设置RelativeLayout为的宽 ...

  5. Emmet 简介

    Emmet 简介 Intro 什么是 Emmet? Emmet is a plugin for many popular text editors which greatly improves HTM ...

  6. 记阿里云SLB后配置Nginx反向代理百度地图API的坑

    需求: 百度的原始请求:https://api.map.baidu.com/place/v2/suggestion?query=s&region=sc&city_limit=true& ...

  7. SQL Server 迁移至MySQL 关键步骤的梳理总结

    迁移主要是通过Navicat工具来实现的.迁移工具的选定在此不讨论. 迁移前准备 1.提前通知DBA\SA\BI等,并确认发布计划及数据库迁移方案. 2.梳理出SQL  Server DB 中影响业务 ...

  8. MongoDB更需要好的模式设计 及 案例赏析

    一  挑战 设计从来就是个挑战. 当我们第一次接触数据库,学习数据库基础理论时,都需要学习范式,老师也一再强调范式是设计的基础.范式是这门课程中的重要部分,在期末考试中也一定是个重要考点.如果我们当年 ...

  9. net view 提示6118错误 解决方法。

    1.win+R ,输入services.msc 开启服务:Server ,WorkStation,computer Browser 2.如果你的电脑没有computer Browser服务,win+R ...

  10. 【转贴】一次 JDBC 与 MySQL 因 “CST” 时区协商误解导致时间差了 14 或 13 小时的排错经历

    原文:https://juejin.im/post/5902e087da2f60005df05c3d ------------------------------------------------- ...