#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 (莫比乌斯反演基础题)

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

  4. [SPOJ VLATTICE]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. Visible Lattice Points GCD问题 莫比乌斯反演

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

  6. SPOJ 7001. 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 莫比乌斯,分块

    题目: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. 理解什么是适配器(adapter)和接口(interface)

    ● 适配器(adapter) In computing, adapter is a hardware device or software component that converts transm ...

  2. 第三周博客之二---Oracle中的sql语句

    一.用户及权限(DBA有最高系统权限) 1.数据库的安全性:系统的安全性.数据的安全性 2.权限分类: 2.1系统权限:获得后可访问数据库 常用的有create table,create user,c ...

  3. 类 Arrays StringBuilder 跟 StringBuffer 的异同 SimpleDateFormat

    类 String 同:起连接字符串类型作用 异: StringBuffer    //线程安全  效率慢 StringBuilder   //线程不安全  效率快 类 Arrays copyOf  ( ...

  4. 常见图片格式PNG,JPEG,BMP,GIF区别总结

    在前端工作久了经常会遇到各种格式的图片文件,现文做一些区别总结,帮助理解但不深入. [PNG](Portable Network Graphics) PNG是一种无损压缩的位图图形格式,主要有PNG8 ...

  5. ykit入门

    init  lint pack server  watch 1.创建现有工程的ykit项目 在项目文件夹下 ykit init 2.lint 检查当前项目的代码质量 手动执行代码 可验证代码正误 yk ...

  6. java中的异常处理问题。

    异常处理--基本概念 当出现程序无法控制的外部环境问题(用户提供的文件不存在,文件内容损坏,网络不可用...)时,JAVA就会用异常对象来描述. java中用2种方法处理异常: 1.在发生异常的地方直 ...

  7. 从网络上获取图片,并写入excel文件

    package com.weChat.utils; import com.manage.utils.DateUtil;import com.manage.utils.MD5Util;import or ...

  8. .NET并行计算和并发11:并发接口 IProducerConsumerCollection

    using System; using System.Collections; using System.Collections.Generic; using System.Collections.C ...

  9. 删除csdn上面自己上传的资源

    今天想删掉以前的资源,才发现CSDN并没有提供删除资源的功能,然后去网上搜了下,这才删除了,不知道怎么删除的小伙伴看过来~ 首先,找到自己要删除资源的页面,举个栗子 https://download. ...

  10. 微信小程序调用快递物流查询API的实现方法

    一. 创建index.wxml.index.wxss.index.js 附上代码: <view class='container'> <input class='info' plac ...