[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 ...
随机推荐
- 【算法学习】Fhq-Treap(无旋Treap)
Treap——大名鼎鼎的随机二叉查找树,以优异的性能和简单的实现在OIer们中广泛流传. 这篇blog介绍一种不需要旋转操作来维护的Treap,即无旋Treap,也称Fhq-Treap. 它的巧妙之处 ...
- 4 - django-orm基本使用
目录 1 数据库与ORM 2 orm的配置 2.1 引擎和配置 2.2 mysql驱动程序 3 orm 表模型 3.1 创建表对象 3.2 Django字段类型 3.3 常用字段参数说明 3.4 特殊 ...
- maven profile 优先级
maven profile是有优先级别 也就是说在setting.xml的profile优先级比pom中同名的profile高. 可以使用 mvn help:active-profiles 这个命令是 ...
- Owin WebApi版本控制
public class WebApiControllerSelector : IHttpControllerSelector { private const string NamespaceKey ...
- Java基础82 jsp中的EL表达式(网页知识)
1.EL表达式的作用 EL表达式的作用:向浏览器输出域对象中的变量值或者表达式计算结果.语法:${变量或者表达式} 注: Jsp的核心语法:jsp的表达式<%= %>和jsp的脚本< ...
- matlab转python
最近在做把matlab代码转成python代码,没有用过matlab,python也只是局限于爬虫,所以.... matlab与python最大的不同是,matlab的下标是从1开始的,python和 ...
- (五)HttpClient 连接超时及读取超时
第一节: HttpClient 连接超时及读取超时 HttpClient连接超时及读取超时 httpClient在执行具体http请求时候 有一个连接的时间和读取内容的时间: HttpClient连接 ...
- MySQL学习笔记:删除存储过程和函数
删除存储过程.存储函数主要使用drop语句: drop procedure —— 删除存储过程 drop function —— 删除存储函数 语法: DROP {PROCEDURE|FUNCTI ...
- VMware虚拟机的三种联网方法及原理(转)
转自:http://blog.chinaunix.net/uid-24876683-id-3593774.html 一.Brigde——桥接 :默认使用VMnet0 .原理: Bridge 桥&quo ...
- MP3 Fuzz学习
这篇文章主要是学习一波MP3格式fuzz的知识.目录如下 0x0.MP3格式的构成 0x0.MP3格式的构成 MP3是一种通俗叫法,学名叫MPEG1 Layer-3.MP3是三段式的结构,依次由ID3 ...