题意:

就是求1-n中有多少对i 和 j 的最小公倍数为n  (i <= j)

解析:

而这题,我们假设( a , b ) = n ,那么:

n=pk11pk22⋯pkss,

a=pd11pd22⋯pdss, b=pe11pe22⋯pess,

可以确定max(ei,di)=ki,      关于这点 可以自己反证一下

那么ki的组成就是ei与di中一个等于ki,

另一个任取[0,ki-1]中的一个数,

那么就有 2ki 种方案,

由于 ei=di=ki 只有一种,(两种都为ki)

所以第i位方案数为2ki+1,

有序对(a,b)方案数就是(2k1+1)(2k2+1)⋯(2ks+1),

无序对(a,b)方案数就是:{[(2k1+1)(2k2+1)⋯(2ks+1)] + 1}/2

(n,n)已经只有一个,不会重复,所以+1 再除 2。

题解转载至:https://blog.csdn.net/qq_15714857/article/details/48641121

代码:

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <sstream>
  4. #include <cstring>
  5. #include <map>
  6. #include <set>
  7. #include <vector>
  8. #include <stack>
  9. #include <queue>
  10. #include <algorithm>
  11. #include <cmath>
  12. #define MOD 2018
  13. #define LL long long
  14. #define ULL unsigned long long
  15. #define maxn 10000900
  16. #define Pair pair<int, int>
  17. #define mem(a, b) memset(a, b, sizeof(a))
  18. #define _ ios_base::sync_with_stdio(0),cin.tie(0)
  19. //freopen("1.txt", "r", stdin);
  20. using namespace std;
  21. const int LL_INF = 0x7fffffffffffffff,INF = 0x3f3f3f3f;
  22. LL primes[maxn/];
  23. bool vis[maxn];
  24. LL ans = ;
  25. void init()
  26. {
  27. mem(vis,);
  28. for(int i=; i<maxn; i++)
  29. if(!vis[i])
  30. {
  31. primes[ans++] = i;
  32. for(LL j=(LL)i*i; j<maxn; j+=i)
  33. vis[j] = ;
  34. }
  35. }
  36.  
  37. int main()
  38. {
  39. init();
  40. int T;
  41. int kase = ;
  42. cin>> T;
  43. while(T--)
  44. {
  45. LL n, res = , cnt = ;
  46. cin>> n;
  47. for(LL i=; i<ans && primes[i] * primes[i] <= n; i++)
  48. {
  49. LL cnt2 = ;
  50. while(n % primes[i] == )
  51. {
  52. n /= primes[i];
  53. cnt2++;
  54. }
  55. if(cnt2 > )
  56. {
  57. res *= (*cnt2 + );
  58. }
  59. }
  60. if(n > )
  61. {
  62. res *= ;
  63. }
  64. printf("Case %d: %lld\n",++kase,res/+);
  65. }
  66. return ;
  67. }

Pairs Forming LCM LightOJ - 1236 (算术基本定理)的更多相关文章

  1. Pairs Forming LCM LightOJ - 1236 素因子分解

    Find the result of the following code: long long pairsFormLCM( int n ) {    long long res = 0;    fo ...

  2. G - Pairs Forming LCM LightOJ - 1236 (质因子分解)

    题解:这道题要从n的角度来考虑i和j. n可以表示为n=a1^p1*a2^p2*a3^p3.......n=lcm(i,j),那么质因子a1^p1,a1可以在i或者j中,并且p1=max(a1i,a1 ...

  3. Pairs Forming LCM (LightOJ - 1236)【简单数论】【质因数分解】【算术基本定理】(未完成)

    Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of t ...

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

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

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

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

  6. 1236 - Pairs Forming LCM

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

  7. Pairs Forming LCM(素因子分解)

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=109329#problem/B    全题在文末. 题意:在a,b中(a,b<=n) ...

  8. Pairs Forming LCM (LCM+ 唯一分解定理)题解

    Pairs Forming LCM Find the result of the following code: ; i <= n; i++ )        for( int j = i; j ...

  9. Pairs Forming LCM

    题目: B - Pairs Forming LCM Time Limit:2000MS     Memory Limit:32768KB Description Find the result of ...

随机推荐

  1. GIT 管理修改、删除文件

    管理修改 现在,假定你已经完全掌握了暂存区的概念.下面,我们要讨论的就是,为什么Git比其他版本控制系统设计得优秀,因为Git跟踪并管理的是修改,而非文件. 你会问,什么是修改?比如你新增了一行,这就 ...

  2. React-使用styled-components

    1.安装 npm install --save styled-components 2.简单使用 style.js: import styled from 'styled-components'; i ...

  3. jQuery webcam plugin

    jQuery webcam plugin The jQuery webcam plugin is a transparent layer to communicate with a camera di ...

  4. Topshelf的Ioc实现

    在前面使用Topshelf的文章里,我们的工作类TownCrier使用的是无参数的构造函数,满足测试的目的.在实际的开发过程中,我们常常需要使用带有参数的构造函数,就不可避免的使用Ioc的技术.在这里 ...

  5. hibernate 解决 java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.xxx 这类的问题

    <!-- 解决 java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.intern ...

  6. 利用卷积神经网络(VGG19)实现火灾分类(附tensorflow代码及训练集)

    源码地址 https://github.com/stephen-v/tensorflow_vgg_classify 1. VGG介绍 1.1. VGG模型结构 1.2. VGG19架构 2. 用Ten ...

  7. Puppet常识梳理

    Puppet简单介绍 1)puppet是一种Linux/Unix平台下的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件.用户.cron任务.软件包.系统服务等.puppet把这些系统 ...

  8. Zookeeper Ephemeral结点使用心得

    原文地址:https://www.cnblogs.com/linlemo/p/4807178.html 公司里面在拿Zookeeper做命名服务,通过使用ZK,前端只需要根据指定的ZK地址获得相应的资 ...

  9. cross-env简介

    是什么 运行跨平台设置和使用环境变量的脚本 出现原因 当您使用NODE_ENV =production, 来设置环境变量时,大多数Windows命令提示将会阻塞(报错). (异常是Windows上的B ...

  10. Daily Scrumming* 2015.12.21(Day 13)

    一.团队scrum meeting照片 大部分成员编译请假,故今天没有开scrum meeting 二.成员工作总结 姓名 任务ID 迁入记录 江昊 无 无 任务说明: 今日准备编译测验,请假 遇到问 ...