http://lightoj.com/volume_showproblem.php?problem=1236

题目大意: 给你一个数n,让你求1到n之间的数(a,b && a<=b)两个数的最小公倍数等于n有多少对这样的ab.

分析都写在图片上了,费了我好大的事呢

ac代码

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue> using namespace std;
typedef long long LL;
#define N 10010001
#define ESP 1e-8
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a)) LL prime[], k;
bool vis[N]; void Prime()
{
memset(vis, false);
k = ;
for(int i=; i<N; i++)
{
if(vis[i] == )
{
prime[k ++] = i;
for(int j= i+i; j<N; j+=i)
{
vis[j] = ;
}
}
}
} LL solve(LL n)
{
LL ans, sum;
ans = ;
sum = ;
for(int i=; prime[i] * prime[i] <= n; i++)
{
if(n%prime[i] == )
{
ans=;
while(n%prime[i] == )
{
ans ++;
n /= prime[i];
}
sum *= (*ans+);
}
}
if(n>)
sum *= (* + );
return sum;
} int main()
{
int T, t=;
LL n;
Prime();
scanf("%d", &T);
while(T --)
{
LL n;
scanf("%lld", &n); LL sum = solve(n); printf("Case %d: %lld\n", t++, sum/+);
}
return ;
}

1236 - Pairs Forming LCM -- LightOj1236 (LCM)的更多相关文章

  1. LightOJ 1236 Pairs Forming LCM (LCM 唯一分解定理 + 素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1236 Pairs Forming LCM Time Limit:2000MS     Memor ...

  2. 1236 - Pairs Forming LCM

    1236 - Pairs Forming LCM   Find the result of the following code: long long pairsFormLCM( int n ) {  ...

  3. LightOJ 1236 - Pairs Forming LCM(素因子分解)

    B - Pairs Forming LCM Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  4. LightOJ - 1236 - Pairs Forming LCM(唯一分解定理)

    链接: https://vjudge.net/problem/LightOJ-1236 题意: Find the result of the following code: long long pai ...

  5. LightOj 1236 - Pairs Forming LCM (分解素因子,LCM )

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1236 题意:给你一个数n,求有多少对(i,  j)满足 LCM(i, j) = n, ...

  6. Light oj 1236 - Pairs Forming LCM (约数的状压思想)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1236 题意很好懂,就是让你求lcm(i , j)的i与j的对数. 可以先预处理1e7以 ...

  7. LightOJ 1236 Pairs Forming LCM 合数分解

    题意:求所有小于等于n的,x,y&&lcm(x,y)==n的个数 分析:因为n是最小公倍数,所以x,y都是n的因子,而且满足这样的因子必须保证互质,由于n=1e14,所以最多大概在2^ ...

  8. LightOj 1236 Pairs Forming LCM (素数筛选&&唯一分解定理)

    题目大意: 有一个数n,满足lcm(i,j)==n并且i<=j时,(i,j)有多少种情况? 解题思路: n可以表示为:n=p1^x1*p2^x1.....pk^xk. 假设lcm(a,b) == ...

  9. LightOJ 1236 Pairs Forming LCM【整数分解】

    题目链接: http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1236 题意: 找与n公倍数为n的个数. 分析: ...

随机推荐

  1. ATL开发 ActiveX控件的 inf文件模板

    ATL开发 ActiveX控件的 inf文件模板    

  2. lnmp

    参照http://www.osyunwei.com/archives/8867.html,略有改动 一 .系统约定 软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/l ...

  3. java 枚举

    DK1.5引入了新的类型——枚举.在 Java 中它虽然算个“小”功能,却给我的开发带来了“大”方便. 用法一:常量 在JDK1.5 之前,我们定义常量都是: publicstaticfianl... ...

  4. ORA-01033: ORACLE 正在初始化或关闭 进程 ID: 0 会话 ID: 0 序列号: 0

    用了很长时间的数据库,一直都挺好,今天早上一来报这个错,开始追究原因. 1.用SYS用户登录: 2.将数据库修改为打开状态,alter database open,出现如下的错误提示: ORA-160 ...

  5. 双二次Lagrange 有限元计算特征值程序(基于iFEM)

    function lambda = c0P2(h) %% Mesh [node,elem] = squarequadmesh([,,,],h); elem = elem(:,[,,,]); showm ...

  6. Android菜鸟成长记8 -- 布局实践(微信界面的编写)

    前面我们简单的介绍了一下android的五大布局,那么现在我们来实践一下,写一个简单的微信界面 首先,我们新建一个weixin.xml的linnerlayout布局 我们日常使用的微信,从简单的方面来 ...

  7. PPTP VPN 限制一个账号只允许一个用户来登录

    创建auth-up文件 vi /etc/ppp/auth-up chmod a+x /etc/ppp/auth-up auth-up脚本内容如下 #!/bin/sh # get the usernam ...

  8. 搭建MySQL MHA高可用

    本文内容参考:http://www.ttlsa.com/mysql/step-one-by-one-deploy-mysql-mha-cluster/ MySQL MHA 高可用集群 环境: Linu ...

  9. LeetCode 445 Add Two Numbers II

    445-Add Two Numbers II You are given two linked lists representing two non-negative numbers. The mos ...

  10. (引用)Python 生成随机数小结

    转载:http://blog.csdn.net/shuaijiasanshao/article/details/51339438