[PE484]Arithmetic Derivative
题意:对整数定义求导因子$'$:$p'=1,(ab)'=a'b+ab'$,求$\sum\limits_{i=2}^n(i,i')$
这个求导定义得比较妙:$(p^e)'=ep^{e-1}$
推一下就可以知道$w(i)=(i,i')$是个积性函数,并且$w(p^e)=p^{e-[e\ne0\pmod p]}$
因为$w(p)=1$,考虑构造$q=w*\mu$,那么$q(p)=0$,又因为$w=q*I$,所以答案为$\sum\limits_{i=1}^nq(i)\left\lfloor\frac ni\right\rfloor-1$
因为$q(p)=0$,所以它只在所有质因子指数$\ge2$的地方有值,这种数可以被表示为$a^2b^3$,其中$b$无平方因子,即使把对$b$的限制去掉,这样的数也只有$\sum\limits_{a=1}^{\left\lfloor\sqrt n\right\rfloor}\left\lfloor\sqrt[3]{\frac n{a^2}}\right\rfloor=O\left(\sqrt n\right)$个
所以直接爆搜出这些数统计答案即可,时间复杂度$O\left(\sqrt n\right)$
#include<stdio.h>
typedef long long ll;
const int T=70710678;
int pr[4200010],M;
bool np[T+10];
void sieve(){
int i,j;
for(i=2;i<=T;i++){
if(!np[i])pr[++M]=i;
for(j=1;j<=M&&i*pr[j]<=T;j++){
np[i*pr[j]]=1;
if(i%pr[j]==0)break;
}
}
}
ll n,res;
void dfs(int x,ll now,ll f){
if(x>M||now>n/((ll)pr[x]*pr[x])){
res+=n/now*f;
return;
}
dfs(x+1,now,f);
ll t;
int c;
now*=pr[x];
for(t=1,c=2;now<=n/pr[x];t*=pr[x],c++){
now*=pr[x];
dfs(x+1,now,f*(t*(c%pr[x]?pr[x]:pr[x]*pr[x])-((c-1)%pr[x]?t:t*pr[x])));
}
}
int main(){
sieve();
scanf("%lld",&n);
dfs(1,1,1);
printf("%lld",res-1);
}
[PE484]Arithmetic Derivative的更多相关文章
- XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative
题目:Problem A. Arithmetic DerivativeInput file: standard inputOutput file: standard inputTime limit: ...
- 【找规律】【DFS】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative
假设一个数有n个质因子a1,a2,..,an,那么n'=Σ(a1*a2*...*an)/ai. 打个表出来,发现一个数x,如果x'=Kx,那么x一定由K个“基础因子”组成. 这些基础因子是2^2,3^ ...
- XVII Open Cup named after E.V. Pankratiev. GP of Tatarstan
A. Arithmetic Derivative 形如$p^p(p是质数)$的数的比值为$1$,用$k$个这种数相乘得到的数的比值为$k$,爆搜即可. #include<cstdio> # ...
- [LeetCode] Arithmetic Slices II - Subsequence 算数切片之二 - 子序列
A sequence of numbers is called arithmetic if it consists of at least three elements and if the diff ...
- [LeetCode] Arithmetic Slices 算数切片
A sequence of number is called arithmetic if it consists of at least three elements and if the diffe ...
- 52. 不用+、-、×、÷做加法[add two numbers without arithmetic]
[本文链接] http://www.cnblogs.com/hellogiser/p/add-two-numbers-without-arithmetic.html [题目] 写一个函数,求两个整数的 ...
- Codeforces Round #342 (Div. 2) D. Finals in arithmetic(想法题/构造题)
传送门 Description Vitya is studying in the third grade. During the last math lesson all the pupils wro ...
- Derivative of the softmax loss function
Back-propagation in a nerual network with a Softmax classifier, which uses the Softmax function: \[\ ...
- CodeChef COUNTARI Arithmetic Progressions(分块 + FFT)
题目 Source http://vjudge.net/problem/142058 Description Given N integers A1, A2, …. AN, Dexter wants ...
随机推荐
- js面向对象编程思想
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 子查询优化--explain与profiling分析语句
今天想的利用explain与progiling分析下语句然后进行优化.本文重点是如何通过explain与profiling分析SQL执行过程与性能.进而明白索引的重要性. 表的关系如下所示: 原始的查 ...
- js实现数组、对象深度克隆的两种办法
1.深度克隆的原理 JS中的深度克隆,指的是原对象改变了,克隆出来的新对象也不会改变,原对象与新对象是完全独立的关系. 实现深度克隆的原理得从对象是一种引用类型说起 众所周知,对象是一种引用类型,对象 ...
- perl6 HTTP::UserAgent发送post
use HTTP::UserAgent; my $ua = HTTP::UserAgent.new; say 'All method:'; say $ua.^methods; my %data = : ...
- 2018 CCPC网络赛
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...
- MySQL 联合查询
联合查询:将多次查询(多条select语句), 在记录上进行拼接(字段不会增加) 基本语法:多条select语句构成: 每一条select语句获取的字段数必须严格一致(但是字段类型无关) 语法 Sel ...
- Java基础83 JSP标签及jsp自定义标签(网页知识)
1.JSP标签 替代jsp脚本,用于jsp中执行java代码1.1.内置标签: <jsp:forward></jsp:forward> 相当于:request.getReu ...
- CentOS6.9 安装OpenResty
1.安装依赖包 yum install -y gcc gcc-c++ readline-devel pcre-devel openssl-devel tcl perl 2.安装OpenResty 首先 ...
- ETL工具kettle基本使用
1.下载kettle:https://sourceforge.net/projects/pentaho/files/Data%20Integration/7.0/pdi-ce-7.0.0.0-25.z ...
- **PHP foreach 如何判断为数组最后一个最高效?
http://www.zhihu.com/question/20158667 其他方法: $list = array('a', 'b', 'c'); foreach($list as $k=>$ ...