Codeforces 448E - Divisors】的更多相关文章

448E - Divisors 思路: dfs.注意如果是1,直接返回,因为1的因子还是1. 因为x因子的因子还是x的因子,所以可以事先处理好x因子的因子在x因子中的位置. 不用这个方法也可以,用map映射vector保存因子的因子. 代码1: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem memset(a,b,sizeof(a)) ; vec…
题目链接:1033D - Divisors 题目大意:给定\(n\)个数\(a_i\),每个数的约数个数为3到5个,求\(\prod_{i=1}^{n}a_i\)的约数个数.其中\(1 \leq n \leq 500 , 1 \leq a_i \leq 2\cdot 10^{18}\). 题解:考虑约数个数公式,可以发现对于任意的\(a_i\),有\(a_i=\left\{\begin{matrix}p^2\\ p^3\\ p^4\\ p_1\cdot p_2\end{matrix}\right…
Common Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. Your task is to say the number of such positive integers xx such that x…
B. Petya and Divisors Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/111/problem/B Description Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given n queries in t…
CodeForces - 27E Number With The Given Amount Of Divisors Submit Status Description Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018. Input The…
codeforces 703E Mishka and Divisors 题面 给出大小为\(1000\)的数组和一个数\(k\),求长度最短的一个子序列使得子序列的元素之积是\(k\)的倍数,如果有多个解输出元素和最小的序列. \(k\)和数组元素的数量级都是\(1e12\). 题解 \(f[i][d]\)表示前\(i\)项是\(d\)的倍数的最优解.因为\(d\)只可能是\(k\)的因数,所以离散化一下\(k\)的因数即可. 过程中需要多次求\(gcd\),直接求会超时.需要先预处理\(b[i…
F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a is divisible by another integer b, then b is called the divisor of a. For example: 12 has positive 6 divisors. They are 1, 2, 3, 4, 6 and 12. Let's def…
Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/article/details/47663477,http://www.cnblogs.com/chenxiwenruo/p/3546457.html),然后取出最小循环节,如果最小循环节不相同答案就是0,否则求出各个字符串含有的最小循环节的数量,求这两个数量的公因数个数(也就是最大公因数的因子个数)就是答案.…
题目:Petya and Divisors传送门: http://codeforces.com/problemset/problem/111/B http://codeforces.com/problemset/problem/112/D 分析: 很容易想到读入x[i].y[i],寻找x[i]的因数,判断一下是不是x[i-y[i]].x[i-y[i]+1]...x[i-1]的某个数因数:但这样会超时:考虑以下两个优化:(1)寻找x[i]因数时循环范围只需要从j∈[0,sqrt(x[i])],但循…
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given the number n, find the smallest positive integer which has exactly n divisors. It is guara…