题意:对整数定义求导因子$'$:$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的更多相关文章

  1. 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: ...

  2. 【找规律】【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^ ...

  3. XVII Open Cup named after E.V. Pankratiev. GP of Tatarstan

    A. Arithmetic Derivative 形如$p^p(p是质数)$的数的比值为$1$,用$k$个这种数相乘得到的数的比值为$k$,爆搜即可. #include<cstdio> # ...

  4. [LeetCode] Arithmetic Slices II - Subsequence 算数切片之二 - 子序列

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the diff ...

  5. [LeetCode] Arithmetic Slices 算数切片

    A sequence of number is called arithmetic if it consists of at least three elements and if the diffe ...

  6. 52. 不用+、-、×、÷做加法[add two numbers without arithmetic]

    [本文链接] http://www.cnblogs.com/hellogiser/p/add-two-numbers-without-arithmetic.html [题目] 写一个函数,求两个整数的 ...

  7. 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 ...

  8. Derivative of the softmax loss function

    Back-propagation in a nerual network with a Softmax classifier, which uses the Softmax function: \[\ ...

  9. CodeChef COUNTARI Arithmetic Progressions(分块 + FFT)

    题目 Source http://vjudge.net/problem/142058 Description Given N integers A1, A2, …. AN, Dexter wants ...

随机推荐

  1. [转]softmax函数详解

    答案来自专栏:机器学习算法与自然语言处理 详解softmax函数以及相关求导过程 这几天学习了一下softmax激活函数,以及它的梯度求导过程,整理一下便于分享和交流. softmax函数 softm ...

  2. 20165230 2017-2018-2 《Java程序设计》第9周学习总结

    20165230 2017-2018-2 <Java程序设计>第9周学习总结 教材学习内容总结 第十二章 java网络编程 学习了用于网络编程的类,了解URL.Socket.InetAdd ...

  3. Cesium entity click

    var url = 'http://202.107.245.51:81/user/dev/api/v2/sql?rows_per_page=40&page=0&sort_order=a ...

  4. 深度解析:python之浅拷贝与深拷贝

    深度解析python之浅拷贝与深拷贝 本文包括知识点: 1.copy与deepcopy 2.可变类型与不可变类型 1.copy与deepcopy 在日常python编码过程中,经常会遇见变量的赋值.这 ...

  5. linux bash shell之declare

    一. #Set the right GC options based on the what we are runningdeclare -a server_cmds=("master&qu ...

  6. springboot配置fastjson后端往前端传输格式化

    import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.Spri ...

  7. tmux 使用

    tmux命令参数 tmux new -s name //创建一个新会话 tmux ls //列出所有会话 tmux a -t name //返回某一个会话 tmux内部命令(ctrl+b之后按) s ...

  8. hihoCoder #1183 : 连通性一·割边与割点(求割边与各点模板)

    #1183 : 连通性一·割边与割点 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 还记得上次小Hi和小Ho学校被黑客攻击的事情么,那一次攻击最后造成了学校网络数据的丢 ...

  9. 接口测试工具--Poster与Postman的简单实用

    HTTP/SOAP协议接口的功能测试: 1.浏览器URL(GET请求) http://127.0.0.1:8000/login/?username=zhangsan&password=1234 ...

  10. INNODB表快速迁移

    本实验在一台server上启动了2个mysql实例端口分别是3307   3308,目的是将3307的表aaa迁移到3308中去,并打开3308的slave 1.在3308上 mysql> dr ...