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. ASP.NET Misconfiguration: Debug Information

    Abstract: Debugging messages help attackers learn about the system and plan a form of attack. Explan ...

  2. Oracle 的递归查询将层级变成字符串

    select A.PARENT_GROUP_ID, A.GROUP_ID,sys_connect_by_path(A.GROUP_ID,'/') || '/' path from dam_dataen ...

  3. java -json()

    json-lib和org.json的使用几乎是相同的,我总结出的区别有两点: 两种包 1. List集合转换成json方法 List list = new ArrayList(); list.add( ...

  4. 转载:java程序打包成jar 配置文件信息路径

    一个普通的java project,里面引用了config.properties配置文件,将项目打成Runnable jar,然后将config.properties放到打包后的jar路径下,执行该j ...

  5. dma驱动

    http://www.crifan.com/files/doc/docbook/dma_pl08x_analysis/release/html/dma_pl08x_analysis.html#idp2 ...

  6. fedora 24下修改IP

    在ROOT环境下 cd /etc/sysconfig/network-scripts 找到类似  ifcfg-enp1s0的文件 sudo vi ifcfg-enp1s0 HWADDR=XX:XX:X ...

  7. Sharif University CTF 2016 -- Android App

    很多种的方案: 方案 A: 直接逆向读代码方案 B: 解包,加入debug信息,重新打包,动态调试方案 C: 解包,改代码加入log.i整出flag, 去掉MainActivity里面d=什么也可以, ...

  8. Python Microsoft Visual C++ Compiler Package for Python 2.7

    错误描述: 在从源代码安装Python模块时遇到此错误.可是我明明从官网下载并安装了Microsoft Visual C++ Compiler Package for Python 2.7,且配置了环 ...

  9. window.location 结构

    属性 含义   protocol 协议   hostname 服务器的名字   port 端口   pathname URL中主机名后的部分   search "?"后的部分,又称 ...

  10. 【Python全栈笔记】05 [模块二] 19 Oct 文件的操作

    文件操作 一般步骤1. 文件打开 2. 文件操作 3. 文件关闭 1. 打开文件 使用open(文件名(绝对路径), 打开模式, 编码) 文件打开的模式有: r:  只读模式(默认) w: 只写模式 ...