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]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很 ...
随机推荐
- P1552 派遣 左偏树
左偏树就是一个应该用堆维护的区间,然后需要进行合并操作而发明的算法,其实这个算法没什么难的,和树剖有点像,维护几个数值,然后递归回来的时候就可以修改. 题干: 题目背景 在一个忍者的帮派里,一些忍者们 ...
- [luogu_U15116]珈百璃堕落的开始
https://www.zybuluo.com/ysner/note/1239458 题面 给定\(n\)个二元组\((x,y)\),问有多少种方案,使得选出其中几个后,\(\sum x=\sum y ...
- bzoj2752
线段树+概率 今天这道题爆零了,奥妙重重. 其实我们可以把式子化成这样:sigma((i-l+1)*(r-i+1)*ai) 这里r减了1 然后展开,(1-l)*(r+1)*ai+(r+l)*i*ai- ...
- 71.Ext.form.ComboBox 完整属性
转自:https://blog.csdn.net/taotaoqi/article/details/7409514 Ext.form.ComboBox 类全称: Ext.form.ComboBox 继 ...
- TypeScript `unknown` 类型
unknown 字面理解和 any 其实没差,任何类型都可赋值给它,但有一点, Anything is assignable to unknown, but unknown isn't assigna ...
- maven+ssm+oracle实现简单的增删改查
首先看一下项目结构 第一步先导入jar包 pom.xml <properties> <spring.version>4.3.18.RELEASE</spring.vers ...
- ACM_绝对值排序
Why Males And Females Apart? Time Limit: 2000/1000ms (Java/Others) Problem Description: In so many o ...
- STMP服务器发送邮件,本地可以发送但是服务器一直发送不成功;
在官网上查看到信息 考虑到部分云服务商封禁了其内网对外 25 端口的访问, xxxxx 端口号: 2525 xxxxx 端口号: 587 然后,我换了一下端口号就行了,浪费了我三个小时时间,贼尴尬:
- 影响ERP成功实施的因素及实施方法
一.影响ERP实施的因素 1.企业自身管理和认识上的问题.在ERP实施过程中没有用变革管理的理念和方法来策划和管理ERP的实施是导致ERP失败的主要原因. ERP作为一种管理工具他的实施本身就是操作手 ...
- MAC 中安装和使用express
其实window系统和mac的操作在大致上其实是想同的,只是一些细节的区别,以下对在mac下安装和使用express做简要介绍,如有不妥之处请各位大神指教. 一.首先要测试node和npm是否已经正确 ...