B. Filling the Grid 分行和列进行染色,扫完图以后没有被染色的格子数,就是对答案产生的贡献值,wa了一发,因为没看清样例,会有冲突情况产生,这种情况下的答案是0 C. Primes and Multiplication 定义了三种操作 g(x,p)、 f(x,y)、prime(x) ...
分类:
其他好文 时间:
2019-10-02 14:28:27
阅读次数:
72
"C Primes and Multiplication" 思路:找到 的所有质数因子,用一个 储存起来,然后对于每一个质因子来说,我们要找到它对最后的答案的贡献的大小,即要找到它在最后的乘积中出现了多少次。 求解方法: 另外,该题还需要用到快速幂的技巧。 代码: cpp // Created by ...
分类:
其他好文 时间:
2019-10-02 00:53:51
阅读次数:
93
Let’s introduce some definitions that will be needed later. Let 𝑝𝑟𝑖𝑚𝑒(𝑥) be the set of prime divisors of 𝑥. For example, 𝑝𝑟𝑖𝑚𝑒(140)={2,5,7 ...
分类:
其他好文 时间:
2019-10-01 11:41:26
阅读次数:
93
传送门 当然是考虑 $n$ 的每个质数 $p$ 对答案的贡献 考虑 $p^k$ 在 $[1,m]$ 中出现了几次,显然是 $\left \lfloor \frac{m}{p^k} \right \rfloor$ 次 那么对于 $p^k$ ,它目前的贡献就是 $p^{\left \lfloor \fr ...
分类:
其他好文 时间:
2019-09-30 14:28:41
阅读次数:
69
Twin Primes Twin primes are pairs of primes of the form (p; p + 2). The term \twin prime" was coined by PaulStckel (1892-1919). The rst few twin prime ...
分类:
其他好文 时间:
2019-08-29 09:21:43
阅读次数:
65
题目链接:https://leetcode cn.com/problems/count primes/ 题目描述: 统计所有小于非负整数 n 的质数的数量。 示例: 思路: 质数就是除了 和本身找不到其他能除尽的数,思路请看题目的提示! 思路一:暴力法(超时)(大家可以学习一下 的用法, 一般配合 ...
分类:
其他好文 时间:
2019-08-17 21:51:24
阅读次数:
78
算是第二次做这套题吧,感觉从上次考试到现在自己有了挺大提高,提前30min做完了。 7-1 Sexy Primes 读懂题意就行。 1 #include <cstdio> 2 #include <iostream> 3 #include <cmath> 4 #include <algorithm> ...
分类:
其他好文 时间:
2019-08-17 00:29:56
阅读次数:
92
1015 Reversible Primes (20 分) 1015 Reversible Primes (20 分) 1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose "re ...
分类:
其他好文 时间:
2019-08-03 09:15:03
阅读次数:
120
#include using namespace std; #define ll long long #define maxn 200 int primes[maxn],m; bool vis[maxn]; void init(){ for(int i=2;i=maxn)break; vis[i*p... ...
分类:
其他好文 时间:
2019-07-04 11:08:29
阅读次数:
104