题目链接:uva 10892 - LCM Cardinality
题目大意:给出l,为说有多少组A,B的最小公约数为l。
解题思路:将L的因子分离出来,因为最大不过几百个,所以可以用o(n^2)暴力枚举一下。
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int N = 1005;
typedef long long ll;
int m;
ll c[N];
void init (ll k) {
m = 0;
ll t = sqrt(k);
for (ll i = 1; i <= t; i++) {
if (k % i == 0) {
c[m++] = i;
if (k / i != i)
c[m++] = k / i;
}
}
sort (c, c + m);
}
ll gcd (ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int solve (ll n) {
int ans = 0;
for (int i = 0; i < m; i++) {
for (int j = i; j < m; j++) {
if (c[i] * c[j] / gcd(c[i], c[j]) == n)
ans++;
}
}
return ans;
}
int main () {
ll n;
while (scanf("%lld", &n), n) {
init (n);
printf("%lld %d\n", n, solve(n));
}
return 0;
}
分享到:
相关推荐
cardinality estimation algorithmPhilippe Flajolet1 and Éric Fusy1 and Olivier Gandouet2 and Frédéric Meunier11Algorithms Project, INRIA–Rocquencourt, F78153 Le Chesnay (France) 2LIRMM, 161 rue Ada...
在分类及预测任务中对高维类别(category)变量的预处理方法
函数周期与遗传算法编码元数,莫鸿强,Zhong Li,本文根据一阶积木块的数量比较不同编码元数的遗传算法应用于单周期和多周期函数时的优化效果。分析表明,遗传算法以多个周期同时
低基数列索引有效性PostgreSQL 和 DB2 的示例程序。DB2 备忘录将 DB2 本机库的路径配置为LD_LIBRARY_PATH 。 例子: LD_LIBRARY_PATH=/opt/ibm/db2/V10.5/lib64在 CLP 中使用分号作为分隔符。 db2 -t
HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm
matlab开发-MaximumCardinalitymatching。构造(非加权)最大基数匹配
资源分类:Python库 所属语言:Python 资源全名:categorical_encoding-0.2.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
$ python main.py --depth 29 --cardinality 4 --base_channels 64 --outdir results CIFAR-10的结果 模型 测试错误(3次运行的中位数) 测试错误(纸上) 训练时间 ResNeXt-29 4x64d 3.89 〜3.75(来自图7) ...
医学图像几种滤波去噪方法,转换为灰度图,归一化图片大小
最终通过analyze table feed_comment_info_id_0000 命令更新了Cardinality ,才能再次用到索引。 排查过程如下: sql语句: select id from feed_comment_info_id_0000 where obj_id=101 and type=1; 索引信息: ...
Stream summarizer and cardinality estimator..zip
Better with Fewer Bits - Improving the Performance of Cardinality Estimation of Large Data Streams (INFOCOM2017)-计算机科学
In an ER model, the cardinality ratio of a relationship type is (a) the number of instances of relationships of that relationship type (b) the number of entity types involved in that relationship ...
cardinality
-- estimate the cardinality of SELECT * FROM src GROUP BY col1, col2; SELECT hll(col1, col2).cardinality from src; -- create hyperloglog cache per hour FROM input_table src INSERT OVERWRITE TABLE ...
优化器(optimizer)是oracle数据库内置的一个核心子系统。优化器的目的是按照一定的判断原则来得到它认为的目标SQL在当前的情形下的最高效的执行路径,也就是为了得到目标SQL的最佳执行计划。依据所选择执行计划时...
New cardinality estimation algorithms for HyperLogLog sketchesOtmar Ertl otmar.ertl@gmail.comFebruary 27, 2017This paper presents new methods to estimate the cardinalities of data sets recorded by ...
基数cardinality是一个 Python 库,用于确定和检查任何可迭代对象的大小。 文档: : Python 包索引 (PyPI): ://pypi.python.org/pypi/cardinality/ 源代码和问题跟踪器: :