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]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很 ...
随机推荐
- 常见的几种异常类型Exception
转自:https://blog.csdn.net/niceworkgogogo/article/details/71746208 算数异常类:ArithmeticExecption 空指针异常类型:N ...
- 要自己当技术使用astgo运营网络电话系统,必须掌握的基本技术
知道什么是centos 知道怎么远程访问centos服务器 (常用工具 Secure Shell Client.WINSCP) 知道重启服务器的命令是 reboot 知道你的服务器是没有图形界面的,所 ...
- struts表单验证xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE validators PUBLIC &quo ...
- C/C++ Python的函数默认参数
发现C/C++ Python的函数可以使用默认参数,来减少传参时候的参数个数. 但是:这样的默认参数最好是不变对象! #include <stdio.h> #include <st ...
- docker容器如何安装vim
mv /etc/apt/sources.list /etc/apt/sources.list.bak && \ echo "deb http://mirrors.16 ...
- javascript:void(0);什么意思
js里面void是一个操作符,该操作符计算表达式的值,但是不返回任何内容. <a href="javascript:void(0);"> 这里用到void(0)表示取消 ...
- c# winform控件dock属性停造位置、摆放顺序详解
dock : [英文释义- 码头.依靠][winform释义- 获取或设置当前控件依靠到父容器的哪一个边缘.] 用途:多数控件都有这个属性,主要用来设置控件的布局. 但对于不太了解这个属性的朋友来说有 ...
- jvm gc日志解读
参考 https://blog.csdn.net/yxc135/article/details/12137663 认识gc日志每个位置的含义 java 8 full gc [Full GC (Meta ...
- Java中常用的操作PDF的类库
iText iText是一个能够快速产生PDF文件的java类库.iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的.它的类库尤其与java Servlet有很好的给合.使用 ...
- mysql中的各种concat
引用:http://www.cnblogs.com/appleat/archive/2012/09/03/2669033.html 一.CONCAT()函数CONCAT()函数用于将多个字符串连接成一 ...