【BZOJ3944】Sum】的更多相关文章

[BZOJ3944]Sum(杜教筛) 题面 求\[\sum_{i=1}^n\mu(i)和\sum_{i=1}^n\phi(i)\] 范围:\(n<2^{31}\) 令\[S(n)=\sum_{i=1}^n\mu(i)\] 随便找个函数\(g\)和\(\mu\)做狄利克雷卷积 \[(g*\mu)(i)=\sum_{d|i}\mu(d)g(\frac{i}{d})\] 对这个玩意求前缀和 \[\sum_{i=1}^n\sum_{d|i}\mu(d)g(\frac{i}{d})\] 把\(d\)给提出…
Description Input 一共T+1行 第1行为数据组数T(T<=10) 第2~T+1行每行一个非负整数N,代表一组询问 Output 一共T行,每行两个用空格分隔的数ans1,ans2 Sample Input 6 1 2 8 13 30 2333 Sample Output 1 1 2 0 22 -2 58 -3 278 -3 1655470 2 Solution 裸的杜教筛.具体的内容详见洲阁2015年的集训队论文.这里我就大致口胡一下,求一个积性函数的前缀和可以把它狄利克雷卷积…
题面 Description Input 一共T+1行 第1行为数据组数T(T<=10) 第2~T+1行每行一个非负整数N,代表一组询问 Output 一共T行,每行两个用空格分隔的数ans1,ans2 Sample Input 6 1 2 8 13 30 2333 Sample Output 1 1 2 0 22 -2 58 -3 278 -3 1655470 2 题目分析 杜教筛模板题.(垃圾卡常题) 套套路即可. 代码实现 #include<iostream> #include&l…
[CF914G]Sum the Fibonacci 题解:给你一个长度为n的数组s.定义五元组(a,b,c,d,e)是合法的当且仅当: 1. $1\le a,b,c,d,e\le n$2. $(s_a|s_b) \& s_c \& (s_d $^$ s_e)=2^i$,i是某个整数3. $s_a \& s_b=0$ 求$\sum f(s_a|s_b) * f(s_c) * f(s_d $^$ s_e)$,f是斐波那契数列,对于所有合法的五元组(a,b,c,d,e).答案模$10^9…
[BZOJ4262]Sum Description Input 第一行一个数 t,表示询问组数. 第一行一个数 t,表示询问组数. 接下来 t 行,每行四个数 l_1, r_1, l_2, r_2. Output 一共 t 行,每行一个数 Sum. Sample Input 4 1 3 5 7 2 4 6 8 1 1 9 9 9 9 1 1 Sample Output 9322587654 9025304064 1065645568 0 HINT 1<=t<=40000,1<=L1<…
Description A young schoolboy would like to calculate the sum for some fixed natural k and different natural n. He observed that calculating ik for all i (1<=i<=n) and summing up results is a too slow way to do it, because the number of required ari…
Portal --> loj6059 Solution ​​ 看过去第一反应是..大力数位dp!然后看了一眼数据范围... ​ 但是这没有什么关系!注意到我们不需要考虑前导零了,可以直接快乐dp ​ 状态还是能继续用的,记\(f[i][j][k]\)表示从左往右数的前\(i\)位,(假装后面没有数位的情况下)模\(p\)余\(j\),数字和为\(k\) ​ 然后..\(n\)特别大所以我们考虑..倍增求解,考虑从\(\lfloor\frac{i}{2}\rfloor\)转移到\(i\): \[…
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \ 2 3…
问题描述: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. 问题分析: 首先我们可以分析人们是如何做十进制的加法的,比如是如何得出5+17=22这个结果的.实际上,我们可以分成三步的:第一步只做各位相加不进位,此时相加的结果是12(个位数5和7相加不要进位是2,十位数0和…
简单的素数打表,然后枚举.开始没注意n读到0结束,TLE了回..下次再认真点.A过后讨论里面有个暴力打表过的,给跪了! #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <cctype> #include <complex.h> #include <cmat…