Visible Lattice Points SPOJ - VLATTICE 三维+莫比乌斯反演

时间:2022-02-18 00:17:01
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e7+;
int vis[maxn];
int mu[maxn];
int prime[maxn];
int tot=;
int sum1[maxn];
int sum2[maxn];
void get_mu()
{
mu[]=; vis[]=;
for(int i=;i<maxn;i++)
{
if(!vis[i]) {mu[i]=-; prime[++tot]=i; }
for(int j=;j<=tot && i*prime[j]<maxn;j++)
{
vis[i*prime[j]]=;
if(i%prime[j]==) break;
mu[i*prime[j]]=-mu[i];
}
}
for(int i=;i<maxn;i++)
sum2[i]=sum2[i-]+mu[i];
}
int main()
{
get_mu();
int T; cin>>T;
while(T--)
{
int n; cin>>n;
ll ans=;
for(int l=,r;l<=n;l=r+)
{
r=n/(n/l);
ans+=(sum2[r]-sum2[l-])*1ll*(n/l)*(n/l)*(n/l);
ans+=(sum2[r]-sum2[l-])*1ll*(n/l)*(n/l)*;
}
cout<<ans+<<endl;
}
}

Visible Lattice Points SPOJ - VLATTICE 三维+莫比乌斯反演的更多相关文章

  1. SPOJ VLATTICE (莫比乌斯反演)

    传送门:https://www.spoj.com/problems/VLATTICE/en/ 题意: 在三维坐标系下,你在点(0,0,0),看的范围是(n,n,n)以内,求你可以看见多少个点没有被遮挡 ...

  2. SPOJ VLATTICE(莫比乌斯反演)

    题意: 在一个三维空间中,已知(0,0,0)和(n,n,n),求从原点可以看见多少个点 思路: 如果要能看见,即两点之间没有点,所以gcd(a,b,c) = 1         /*来自kuangbi ...

  3. SPOJ VLATTICE Visible Lattice Points &lpar;莫比乌斯反演基础题&rpar;

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

  4. &lbrack;SPOJ VLATTICE&rsqb;Visible Lattice Points 数论 莫比乌斯反演

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

  5. spoj 7001&period; Visible Lattice Points GCD问题 莫比乌斯反演

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

  6. SPOJ 7001&period; Visible Lattice Points (莫比乌斯反演)

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

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

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

  8. Spoj 7001 Visible Lattice Points 莫比乌斯&comma;分块

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

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

    Visible Lattice Points 题意 : 从(0,0,0)出发在(N,N,N)范围内有多少条不从重合的直线:我们只要求gcd(x,y,z) = 1; 的点有多少个就可以了: 比如 : 点 ...

随机推荐

  1. 在cmd命令行使用Maven Archetype插件 generate命令创建简单的java web项目

    前提: 1.下载apache-maven:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache ...

  2. opencv 中对一个像素的rgb值或像素值进行操作的几个常用小办法【转】

    You can access the Image pixels in many ways:1. One using the Inbuilt macro2. One using the pointer ...

  3. leveldb - 并发写入处理

    在并发写入的时候,leveldb巧妙地利用一个时间窗口做batch写入,这部分代码值得一读: Status DBImpl::Write(const WriteOptions& options, ...

  4. Rectangle Intersection Test &lpar;with C&num;&rpar;

    Rectangle Intersection Test (with C#) by Sebastian Krysmanskihttp://manski.net/2011/05/rectangle-int ...

  5. MySQL:MySQL和SQL Server的区别

    导读:接下来的网上商城的项目,需要用到MySQL数据库了.这个对于我来说,是一个新接触的东西,按照惯例,在刚开始学习一个东西的时候,先从宏观上去了解它.本篇博客,先介绍SQL Server的基本内容, ...

  6. 从Count看Oracle执行计划的选择

    一. 前言 在调查一个性能问题的时候,一个同事问道,为什么数据库有些时候这么不聪明,明明表上有索引,但是在执行一个简单的count的时候居然全表扫描了!难道不知道走索引更快么? 试图从最简单的coun ...

  7. &lbrack;Linux&rsqb;XAMPP安装

    XAMPP安装下载地址:http://xiazai.zol.com.cn/index.php?c=Detail_DetailMini&n=19e18f86d0596b5cd&softi ...

  8. C&num;中使用日志类,添加dll时出现错误

    警告 1 未能解析引用的程序集 “log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, proces ...

  9. vue 中的translation操作----动态值

    在vue中,也会遇见translate的情况,这里顺带也可以带上如何查找页面中的元素的案例. 1.在加载过程中,有会遇见加载顺序先后的问题,然后查找页面元素null的情况,所以在mounted的钩子函 ...

  10. 刚发了两个关于极光推送的网上Demo,再次自己结合官网总结一下,以便加深印象

    简单源码如下: //Map<String, String> parm是我自己传过来的参数,同学们可以自定义参数public static void jpushAndroid(Map< ...