题意就是给你一个数让你找它的正因子个数(包括自身,不包括1),这个地方用到一个公式,如果不用的话按正常思路来写会TL什么的反正就是不容易写对。

求任意一个大于1的整数的正因子个数

首先任意一个数n,n=P1^a1 * P2^a2 * P3^a3 *……Pn^an;

任意的整数n可以分解为m个素数ai次幂的连续乘机,这个地方解释不清自己再理解一下(Pi都为素数,依次往后pi越来越大,ai就是次幂,自己可以找几个任意整数n来套一下这个公式就会明白了)

然后正因子个数和:sum=(1+a1)*(1+a2)*(1+a3)……*(1+an);

用这两个公式本题就可以轻松解决啦(这里还是不清楚的就套几个数就理解这两个公式了,是完全正确的哦);

AC代码如下:

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int pri[];
int tt[];
int s=;
void dabiao() //打个素数表会节省很多时间
{ int j;
memset(tt,,sizeof(tt));
tt[]=;
tt[]=;
for(int i=;i<=;i++)
{
if(tt[i]!=)
{
pri[s++]=i;
for(j=i+i;j<=;j+=i)
tt[j]=;
}
}
return ;
}
int main()
{
int m,i,j,k,t,cas=;
long long n,num,ans;
scanf("%d",&t);
dabiao();
while(t--)
{
scanf("%lld",&n);
num=;
for(i=;i<s&&pri[i]*pri[i]<=n;i++)
{
ans=;
if(n%pri[i]==)
{ while(n%pri[i]==)//此处就是来找素数的N次幂,存起来相乘来计算SUM
{
ans++;
n/=pri[i];
} }
num=num*(ans+);
}
if(n>)//这个地方就不解释啦,自己想想咯
num*=;
printf("Case %d: %lld\n",++cas,num-);
}
return ;
}

Trailing Zeroes (I) LightOJ - 1028的更多相关文章

  1. Trailing Zeroes (I) LightOJ - 1028(求因子个数)

    题意: 给出一个N 求N有多少个别的进制的数有后导零 解析: 对于一个别的进制的数要转化为10进制 (我们暂且只分析二进制就好啦) An * 2^(n-1) + An-1 * 2^(n-2) + `` ...

  2. Trailing Zeroes (III)(lightoj 二分好题)

    1138 - Trailing Zeroes (III)   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit:  ...

  3. Trailing Zeroes (III) LightOJ - 1138(二分)

    You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in d ...

  4. Trailing Zeroes (III) LightOJ - 1138 二分+找规律

    Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural number N, so that N! ...

  5. Trailing Zeroes (II) LightOJ - 1090(预处理+前缀和)

    求C(n,r)*p^q的后缀零 考虑一下 是不是就是求 10^k*m  的k的最大值 而10又是由2 和 5 组成  所以即是求 2^k1 * 5^k2 * m1 中k1和k2小的那一个数 短板效应嘛 ...

  6. Trailing Zeroes (III) LightOJ - 1138 不找规律-理智推断-二分

    其实有几个尾零代表10的几次方但是10=2*510^n=2^n*5^n2增长的远比5快,所以只用考虑N!中有几个5就行了 代码看别人的: https://blog.csdn.net/qq_422797 ...

  7. LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

    http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     M ...

  8. LightOJ Trailing Zeroes (III) 1138【二分搜索+阶乘分解】

    1138 - Trailing Zeroes (III) PDF (English) problem=1138" style="color:rgb(79,107,114)" ...

  9. Trailing Zeroes (III) -;lightoj 1138

    Trailing Zeroes (III)   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Y ...

随机推荐

  1. kali linux常用软件配置记录

    首先膜一波,认真细致,简明有效. 感谢原博主的分享,留作参考. https://www.cnblogs.com/youfang/p/5272746.html

  2. linux下can调试工具canutils安装过程记录

    https://www.cnblogs.com/chenfulin5/p/6797756.html 一.下载源码 下载canutils和libsocketcan libsocketcan地址:http ...

  3. Python笔记 #19# 实现bpnn

    代码编辑&解释工具:Jupyter Notebook 快速入门 形象说明BP神经网络的用法(图片来自推特): Bpnn类最主要的三个方法: initialize方法,用于设定神经网络的层数.各 ...

  4. Percona Server 5.6 安装TokuDB

    系统:Red Hat Enterprise Linux Server release 6.3 (Santiago) 数据库:Percona-Server-5.6.29-rel76.2-Linux.x8 ...

  5. Eclipse中手动清理项目缓存,

    用过Eclipse或MyEclipse的小伙伴肯定遇到过这种情况: 代码出错后,在前台访问出问题.然后把代码改好,已经检查不到错误,可是项目在前台访问还是有问题. 这个时候,可能就是Eclipse/M ...

  6. 程序员编程艺术:面试和算法心得-(转 July)

    1.1 旋转字符串 题目描述 给定一个字符串,要求把字符串前面的若干个字符移动到字符串的尾部,如把字符串“abcdef”前面的2个字符'a'和'b'移动到字符串的尾部,使得原字符串变成字符串“cdef ...

  7. webpack --watch和supervisor的不同

     webpack --watch只是热打包,也就是前端代码的热加载,要实现后端代码的热加载,也就是热部署,需要使用supervisor 如何使用热部署可以参考这里:http://www.cnblogs ...

  8. Codeforces 235C Cyclical Quest - 后缀自动机

    Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in ...

  9. 【Python56--爬取妹子图】

    爬取网站的思路 第一步:首先分析爬取网站的连接地址特性,发现翻页图片的时候连接:http://www.mmjpg.com/mm/1570  ,http://www.mmjpg.com/mm/1569, ...

  10. 【python54--爬虫2】

    1.有道翻译 ''' |-- 代码思路解析: |-- 1.拿到网址首先查看network内Headers的:Request URL:User-Agent:From Data,这几个就是代码所需要的ur ...