hdu 6134 Battlestation Operational 莫比乌斯反演
Battlestation Operational
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
>
> — Wookieepedia
In the story of the Rogue One, the rebels risked their lives stolen the construction plan of the Death Star before it can cause catastrophic damage to the rebel base. According to the documents, the main weapon of the Death Star, the Superlaser, emits asymmetric energy in the battlefield that cause photons to annihilate and burns everything in a single shot.
You are assigned the task to estimate the damage of one shot of the Superlaser.
Assuming that the battlefield is an n×n grid. The energy field ignited by the Superlaser is asymmetric over the grid. For the cell at i-th row and j-th column, ⌈i/j⌉units of damage will be caused. Furthermore, due to the quantum effects, the energies in a cell cancel out if gcd(i,j)≠1 or i<j.
The figure below illustrates the damage caused to each cell for n=100. A cell in black indicates that this cell will not be damaged due to the quantum effects. Otherwise, different colors denote different units of damages.
Your should calculate the total damage to the battlefield. Formally, you should compute
where [(i,j)=1] evaluates to be 1 if gcd(i,j)=1, otherwise 0.
Each line of the input, there is an integer n (1≤n≤106), as described in the problem.
There are up to 104 test cases.
2
3
10
3
8
110
不想写题解!!!!!!!!!
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-4
#define bug(x) cout<<"bug"<<x<<endl;
const int N=3e4+,M=1e6+,inf=1e9+,MOD=1e9+;
const LL INF=1e18+,mod=1e9+; int mu[M], p[M], np[M], cnt;
LL smu[M];
void init()
{
mu[]=;
for(int i=; i<M; ++i)
{
if(!np[i]) p[++cnt]=i, mu[i]=-;
for(int j=; j<=cnt && i*p[j]<M ; ++j)
{
int t=i*p[j];
np[t]=;
if(i%p[j]==)
{
mu[t]=;
break;
}
mu[t]=-mu[i];
}
}
for(int i=; i<M; i++)
smu[i]=smu[i-]+mu[i],smu[i]=(smu[i]%mod+mod)%mod;
}
LL a[M],sum[M],sum2[M];
void init1()
{
for(int j=; j<=; j++)
{
a[j]+=;
a[j+]-=;
a[j+]=(a[j+]%mod+mod)%mod;
a[j]=(a[j]%mod+mod)%mod;
for(int k=;;k++)
{
int L=(k-)*j+;
int R=k*j+;
a[L]+=k;
a[L]%=mod;
if(R>=M)break;
a[R]-=k;
a[R]=(a[R]%mod+mod)%mod;
}
}
for(int i=; i<M; i++)
sum[i]=sum[i-]+a[i],sum[i]%=mod;
for(int i=;i<M;i++)
sum2[i]=sum2[i-]+sum[i],sum2[i]%=mod;
}
int main()
{
init();
init1();
int n;
while(~scanf("%d",&n))
{
LL ans=;
int last=;
for(int i=; i<=n; i=last+)
{
last=(n/(n/i));
ans+=(((smu[last]-smu[i-]+mod)%mod)*sum2[n/i])%mod;
ans=(ans%mod+mod)%mod;
}
printf("%lld\n",ans);
}
return ;
}
Battlestation Operational
Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 20    Accepted Submission(s): 3
>
> — Wookieepedia
In the story of the Rogue One, the rebels risked their lives stolen the construction plan of the Death Star before it can cause catastrophic damage to the rebel base. According to the documents, the main weapon of the Death Star, the Superlaser, emits asymmetric energy in the battlefield that cause photons to annihilate and burns everything in a single shot.
You are assigned the task to estimate the damage of one shot of the Superlaser.
Assuming that the battlefield is an n×n grid. The energy field ignited by the Superlaser is asymmetric over the grid. For the cell at i-th row and j-th column, ⌈i/j⌉units of damage will be caused. Furthermore, due to the quantum effects, the energies in a cell cancel out if gcd(i,j)≠1 or i<j.
The figure below illustrates the damage caused to each cell for n=100. A cell in black indicates that this cell will not be damaged due to the quantum effects. Otherwise, different colors denote different units of damages.
Your should calculate the total damage to the battlefield. Formally, you should compute
where [(i,j)=1] evaluates to be 1 if gcd(i,j)=1, otherwise 0.
Each line of the input, there is an integer n (1≤n≤106), as described in the problem.
There are up to 104 test cases.
2
3
10
3
8
110
hdu 6134 Battlestation Operational 莫比乌斯反演的更多相关文章
- 2017多校第8场 HDU 6134 Battlestation Operational 莫比乌斯反演
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意: 解法: 那么g(n)怎么求,我们尝试打表发现g(n)是有规律的,g(n)=g(n-1)+ ...
 - hdu 6134 Battlestation Operational (莫比乌斯反演+埃式筛)
		
Problem Description > The Death Star, known officially as the DS-1 Orbital Battle Station, also ...
 - HDU 6134 Battlestation Operational(莫比乌斯反演)
		
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6134 [题目大意] 求$\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\ ...
 - 2017ACM暑期多校联合训练 - Team 8 1002      HDU 6134    Battlestation Operational   (数论   莫比乌斯反演)
		
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also k ...
 - hdu 6134: Battlestation Operational  (2017 多校第八场 1002)【莫比乌斯】
		
题目链接 比赛时没抓住重点,对那个受限制的“分数求和”太过关心了..其实如果先利用莫比乌斯函数的一个性质把后面那个[gcd(i,j)=1]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很 ...
 - HDU 6134 Battlestation Operational  |  2017 Multi-University Training Contest 8
		
破结论没听说过,上式推导到第三步的时候有了O(nlogn) 的做法(枚举倍数+1最后前缀和),并且这种做法可以直接应用到向上取整的计算中,详见forever97 但由于d(n)是积性函数,故可O(n) ...
 - hdu6134 Battlestation Operational 莫比乌斯第一种形式
		
/** 题目:hdu6134 Battlestation Operational 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意:f(n) = ...
 - HDU 5321 Beautiful Set (莫比乌斯反演 + 逆元 + 组合数学)
		
题意:给定一个 n 个数的集合,然后让你求两个值, 1.是将这个集合的数进行全排列后的每个区间的gcd之和. 2.是求这个集合的所有的子集的gcd乘以子集大小的和. 析:对于先求出len,len[i] ...
 - HDU 4746 Mophues【莫比乌斯反演】
		
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4746 题意: 1≤x,y≤n , 求gcd(x,y)分解后质因数个数小于等k的(x,y)的对数. 分 ...
 
随机推荐
- 前端框架VUE----计算属性和侦听器
			
一.计算属性 模板内的表达式非常便利,但是设计它们的初衷是用于简单运算的.在模板中放入太多的逻辑会让模板过重且难以维护.例如: <div> {{ message.split('').rev ...
 - Java 注释规范
			
基本的要求: 1.注释形式统一 在整个应用程序中,使用具有一致的标点和结构的样式来构造注释.如果在其它项目中发现它们的注释规范与这份文档不同,按照这份规范写代码,不要试图在既成的规范系统中引入新的规范 ...
 - ajax实现图片上传
			
1.创建formData表单,模拟表单传递数据(formData有兼容性问题) var formData = new FormData();2.获取到相应的元素 var jobName = $(&qu ...
 - 管理mycat命令详解
			
mycat监听两个端口,分别为8066和9066:mycat服务默认的数据端口是8066,而9066端口则是mycat管理端口,用于管理mycat的整个集群状态.监听的端口可以在server.xml配 ...
 - Mysql 按天自动分区,合并老分区
			
适用于每天一个分区...不断加分区,导致分区不够用的情况 CREATE DEFINER=hehe@XXXXXX PROCEDURE p_auto_partition_day(IN databaseNa ...
 - NATS—发布/订阅机制
			
概念 发布/订阅(Publish/subscribe 或pub/sub)是一种消息范式,消息的发送者(发布者)不是计划发送其消息给特定的接收者(订阅者).而是发布的消息分为不同的类别,而不需要知道什么 ...
 - 公网FTP(filezilla)改端口
			
背景:我们如果不修改ftp服务器的端口,很容易被别人测试和攻击. 配置要点:服务端端口设置.主被动设置.服务端和客户端防火墙设置 ftp服务器:filezilla ftp server 1. 监听端 ...
 - 存根类(stub) 是什么意思?有什么作用?(转)
			
存根类是一个类,它实现了一个接口,但是实现后的每个方法都是空的. 它的作用是:如果一个接口有很多方法,如果要实现这个接口,就要实现所有的方法.但是一个类从业务来说,可能只需要其中一两个方法. 如 ...
 - bzoj 4237 稻草人 - CDQ分治 - 单调栈
			
题目传送门 传送点I 传送点II 题目大意 平面上有$n$个点.问存在多少个矩形使得只有左下角和右上角有点. 考虑枚举左下角这个点.然后看一下是个什么情况: 嗯对,是个单调栈.但不可能暴力去求每个点右 ...
 - 数据库 ---  4  多表查询  ,Navicat工具 ,  pymysql模块
			
一.多表查询 1.笛卡儿积 查询 2.连接 语法: ①inner 显示可构成连接的数据 mysql> select employee.id,employee.name,department ...