题意:对整数定义求导因子$'$:$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. 更改arch的默认终端

    实在是厌倦了gnome的资源管理器nautilus和终端gnome-terminal,于是卸载之,然后更换了xfce4的终端,但是出现了一个问题,那就是在资源管理器中使用邮件打开终端的时候打不开了,解 ...

  2. bzoj 4816: 洛谷 P3704: [SDOI2017]数字表格

    洛谷很早以前就写过了,今天交到bzoj发现TLE了. 检查了一下发现自己复杂度是错的. 题目传送门:洛谷P3704. 题意简述: 求 \(\prod_{i=1}^{N}\prod_{j=1}^{M}F ...

  3. 【划水闲谈】Terraria 1.3.5更新

    我知道这本应是一个算法博客,但又有谁规定了不能发点其他内容呢? Terraria,一个有趣的沙盒游戏.在这里,你可以建造,挖掘,开始一次又一次新的冒险. 4月19日,Re-Logic承诺的官方中文版终 ...

  4. torch.normal(means, std, out=None)

    返回满足正态分布的张量 means和std分别给出均值和标准差

  5. souce insight出错 There was an error opening project

    souce insight出错 There was an error opening project: "...": Options->Preferences->Fol ...

  6. skb_pull skb_push skb_put

    unsigned char *skb_pull(struct sk_buff *skb, int len)该函数将 data 指针向数据区的末尾移动,减少了len 字段的长度.该函数可用于从接收到的数 ...

  7. Codeforces 859E Desk Disorder 并查集找环,乘法原理

    题目链接:http://codeforces.com/contest/859/problem/E 题意:有N个人.2N个座位.现在告诉你这N个人它们现在的座位.以及它们想去的座位.每个人可以去它们想去 ...

  8. Spring Boot连接Mysql数据库问题解决

    在spring Boot项目中使用mysql数据库进行数据库的增删查改,出现以下错误: Error starting ApplicationContext. To display the auto-c ...

  9. 八、springboot整合redis

    整合Redis 一. 注解方式实现添加缓存 1.在pom.xml加入依赖 <!-- 配置使用redis启动器 --> <dependency> <groupId>o ...

  10. git内部原理

    Git 内部原理 无论是从之前的章节直接跳到本章,还是读完了其余章节一直到这——你都将在本章见识到 Git 的内部工作原理 和实现方式. 我们发现学习这部分内容对于理解 Git 的用途和强大至关重要. ...