Divisors poj2992
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 9940 | Accepted: 2924 |
Description
Input
Output
Sample Input
5 1
6 3
10 4
Sample Output
2
6
16
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[]={},t,pp[];
void init()
{
int i,j;
t=;
for(i=; i<; i++)
{
if(!p[i])
{
p[t++]=i;
j=i*i;
while(j<)
{
p[j]=;
j+=i;
}
}
}
}
void fun(int n,int q)
{
int i,j,m,sum;
for(i=; p[i]<=n&&i<t; i++)
{
m=n;
sum=;
while(m)
{
m/=p[i];
sum+=m;
}
if(q)
pp[i]+=sum;
else pp[i]-=sum;
}
}
int main()
{
init();
int n,k,i;
while(~scanf("%d%d",&n,&k))
{
memset(pp,,sizeof(pp));
fun(n,);
fun(k,);
fun(n-k,);
long long sum=;
for(i=; i<t; i++)
{
if(pp[i])sum*=pp[i]+;
}
printf("%lld\n",sum);
}
}
Divisors poj2992的更多相关文章
- POJ2992:Divisors(求N!因子的个数,乘性函数,分解n!的质因子(算是找规律))
题目链接:http://poj.org/problem?id=2992 题目要求:Your task in this problem is to determine the number of div ...
- 【POJ2992】Divisors
[题目概括] 计算\(C_n^k\)的因子个数. [思路要点] 首先考虑将组合数展开,展开后就是\(\frac {n!}{k!\times (n-k)!}\). 这样就是计算出这些质因子的个数,然后将 ...
- codeforces 27E Number With The Given Amount Of Divisors
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...
- HDU - The number of divisors(约数) about Humble Numbers
Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence ...
- Divisors
计算小于n的数中,约数个数最多的数,若有多个最输出最小的一个数. http://hihocoder.com/problemset/problem/1187 对于100有 60 = 2 * 2 * 3 ...
- Xenia and Divisors
Xenia and Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- hihocoder1187 Divisors
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given an integer n, for all integers not larger than n, f ...
- The number of divisors(约数) about Humble Numbers[HDU1492]
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- Sum of divisors
Problem Description mmm is learning division, she's so proud of herself that she can figure out the ...
随机推荐
- zip7压缩
7-zip 解压 1.引入依赖文件 sevenzipjbinding.jar sevenzipjbinding-Allwindows.jar <!-- https://mvnrepository ...
- informatica9 安装下载,安装教程 介质(文章和视频教程)(csdn讲师:Array)
Informatica学习: 参考文献:视频参考地址:http://edu.csdn.net/course/detail/5034,ETL之informatica9通关班(第二期) 1.安装介质的获 ...
- union-find算法Java实现
package practice; /*在一个全是点的图中,循环选择两点连通,之后判断两点是否在同一通路*/ public class Testmain { public static void ma ...
- JavaScript中事件
JS中的事件 一.事件分类: 鼠标事件:鼠标单击.鼠标双击.鼠标指上等... HTML事件:文档加载.焦点.表单提交等... 键盘事件:键盘按下(keydown).键盘按下并松开瞬间(keypress ...
- 建立maven工程pom.xml报错:web.xml is missing and <failOnMissingWebXml> is set to true
解决方式:如图添加web.xml文件即可
- 交换机端口呈现err-disable的原因
导致交换机端口呈现err-disable状态的原因有很多,为方便大家查询,特归纳如下: 1. duplex mismatch (A is correct) 2. port-channel misc ...
- ps图层面板上的【透明度】与【填充】的区别
为文字添加投影,分别调图层面板上的[透明度]与[填充]的值你就知道区别了. 如上图降低填充的数值,结果只对文字颜色有影响却对投影毫无影响. 而如上图,调整不透明度的时候对文字颜色与投影均产生效果. 这 ...
- mac环境下安装mysql
一,下载mysql 官网"Community " 下会看到"MySQL Community Server"下方有一个"download"点击 ...
- 团队作业8——第二次项目冲刺(Beta阶段)--第三天
一.Daily Scrum Meeting照片 二.燃尽图 三.项目进展 学号 成员 贡献比 201421123001 廖婷婷 16% 201421123002 翁珊 16% 201421123004 ...
- win8下安装VC6出现兼容性问题的解决办法
重装系统之后(win8的系统),发现VC6安装出现兼容性问题,花了一些时间解决,有出现的问题都差不多在下面链接的总结中,写的很详细: http://www.docin.com/p-1126120829 ...