Battlestation Operational
Battlestation Operational
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Orbital Battle Station, also known as the Death Star I, the First Death Star,
Project Stardust internally, and simply the Ultimate Weapon in early development
stages, was a moon-sized, deep-space mobile battle station constructed by the
Galactic Empire. Designed to fire a single planet-destroying superlaser powered
by massive kyber crystals, it was the pet project of the Emperor, Darth Vader,
and its eventual commander Grand Moff Wilhuff Tarkin to expound the military
philosophy of the aptly named Tarkin Doctrine.
>
> —
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.
denoting the total damage of the Superlaser, f(n) mod 10
.
2
3
10
3
8
110
#include<cstdio>
#define mod 1000000007
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
const int maxn=1e6+;
int n,m,k,t;
long long p[maxn];
void init()
{
int i,j;
rep(i,,maxn-)
{
p[i]++;
p[i+]--;
for(int j=i,cnt=;j+<=maxn-;j+=i,cnt++)
{
p[j+]+=cnt;
if(j+i+<=maxn-)p[j+i+]-=cnt;
}
}
rep(i,,maxn-)p[i]=(p[i]%mod+p[i-]+mod)%mod;
rep(i,,maxn-)
{
for(j=i*;j<=maxn-;j+=i)
{
p[j]=(p[j]-p[i]+mod)%mod;
}
}
rep(i,,maxn-)(p[i]+=p[i-])%=mod;
}
int main()
{
int i,j;
init();
while(~scanf("%d",&n))printf("%lld\n",p[n]);
return ;
}
Battlestation Operational的更多相关文章
- hdu 6134 Battlestation Operational 莫比乌斯反演
Battlestation Operational Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- hdu6134 Battlestation Operational 莫比乌斯第一种形式
/** 题目:hdu6134 Battlestation Operational 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意:f(n) = ...
- 【2017多校训练08 1002】【HDOJ 6134】Battlestation Operational
典型的数列反演题. 运用莫比乌斯反演的一个结论 $[n = 1] = \sum_{d | n} \mu(d)$,将表达式做如下转化: $$ ans = \sum_{i=1}^n \sum_{j=1}^ ...
- 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(莫比乌斯反演)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6134 [题目大意] 求$\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\ ...
- 2017多校第8场 HDU 6134 Battlestation Operational 莫比乌斯反演
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意: 解法: 那么g(n)怎么求,我们尝试打表发现g(n)是有规律的,g(n)=g(n-1)+ ...
- 【数论】【莫比乌斯反演】【线性筛】hdu6134 Battlestation Operational
看这个题解吧:http://blog.csdn.net/wubaizhe/article/details/77338332 代码里顺便把几个常用的线性筛附上了. Key:1.gcd(i,j)==1利用 ...
- HDU 6134 Battlestation Operational | 2017 Multi-University Training Contest 8
破结论没听说过,上式推导到第三步的时候有了O(nlogn) 的做法(枚举倍数+1最后前缀和),并且这种做法可以直接应用到向上取整的计算中,详见forever97 但由于d(n)是积性函数,故可O(n) ...
- hdu 6134: Battlestation Operational (2017 多校第八场 1002)【莫比乌斯】
题目链接 比赛时没抓住重点,对那个受限制的“分数求和”太过关心了..其实如果先利用莫比乌斯函数的一个性质把后面那个[gcd(i,j)=1]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很 ...
随机推荐
- 【NOI2009】Bzoj1562&Codevs1843 变换序列
目录 List Description Input Output Sample Input Sample Output HINT Solution 官方题解%莫队 Code Position: htt ...
- AngularJS 1.x 国际化——Angular-translate例子
可运行代码如下: <!DOCTYPE html> <html ng-app="MyApp"> <head> <meta http-equi ...
- [HNOI2006]潘多拉的宝盒
https://www.zybuluo.com/ysner/note/1250303 题面 给定\(s\)个自动机,如果某个自动机\(A\)能产生的所有串都能在自动机\(B\)中产生(即走相同\(0/ ...
- mvn scope (转)
策略一: 对于容器提供的(如:servlet-api-2.3等)和测试需要时的(如:junit-3.81等),可以直接在pom.xml中去掉. maven的dependency中有一个tag是< ...
- Windows(7/8/10)搭建Elasticsearch 6.x版本
今天公司用到了Elasticsearch ,记录一下单机版搭建的流程. 首先我们来看下什么是Elasticsearch : ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分 ...
- 记一次MySQL索引优化
两张表是主(CHECK_DRAWINGS)从(CHECK_DRAWINGS_IMG)关系. CHECK_DRAWINGS,主表数据 3591条. SELECT COUNT(*) FROM CHECK_ ...
- 汇编程序44:检测点13.1 (jmp near ptr 标号指令的中断例程)
安装程序: assume cs:code //jmp near ptr 标号指令的替代实现,使用iret指令 code segment start: mov ax,cs mov ds,ax mov s ...
- BZOJ 2300凸包+离线
思路: 倒着加显然吧 动态维护这个凸包就好了 //By SiriusRen #include <bits/stdc++.h> using namespace std; ; int n,m ...
- strcpy 和 memcpy自实现
都是套路,详见代码注释: #include <stdio.h> #include <assert.h> #include <iostream> using name ...
- [转]linux之初识SELinux
转自:http://www.linuxidc.com/Linux/2014-07/104447.htm 1.selinux的概述 selinux相信大家一定不会陌生,它的全称是内核级加强型防火墙.在服 ...