当前位置:网站首页>C - Divisors of the Divisors of An Integer Gym - 102040C
C - Divisors of the Divisors of An Integer Gym - 102040C
2022-07-05 14:01:00 【beyond+myself】
Topic link
The question : Is o n! The number of factors in the factor
Answer key :
①:n! The number of a factor in is n/x Accumulation .
prove : In fact, it is one layer at a time , That is, each removal can be divided into 1 individual 3 Of , Two in turn 3 Of , Three 3 The number of , Finally, you can get 3 The number of , There's no need to
to be divisible by , Because it's a factorial , So even if it can't be divisible , It can also be divided by smaller numbers in the array .
Let's give you an example :
1234567 We find what we finally get 2 The number of , for the first time We found that 2 4 6 Divisibility , After division, it becomes 1 2 3 then 7/2=3,ans+=3, then 2 Still divisible , And then it became 1, then 3/2=1, You can't divide the rest , So we can find this rule .
②: Suppose we can turn the result of factorial into something similar to 2 ^ a * 3 ^ b * 5 ^ c In this way , We can get the result —— yes (a+1)*(a+2) / 2 * (b+1) * (b+2) / 2 *(c+1) * (c+2) / 2;
prove : After we write them in the above form , In fact, the factor is easy to find , If you let me find the number of factors , That's all for this question , But the question requires the number of factors , So we can't finish here , The number of factors is —— We just ask
A prime unit , For example :3 ^ 0 The number of factors of is 1 individual ,3 ^ 1 Are the two ,3 ^ a The number of factors ( 3 ^ 0 ~ 3 ^ a) common a+1 individual therefore We add them up to (a+1) * (a+2)/2 such Multiply all of them , That is, the number of cases similar to permutation and combination , When all numbers are selected 0 Inferior time , That is to say 1.
Here is AC Code :
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=1e6+10,mod=1e7+7;
int prime[N];
bool st[N];
int cnt[N];
int cou;
void is_prime(int n)
{
int i,j;
for(i=2;i<=n;i++)
{
if(!st[i])
{
prime[cou++]=i;
for(j=i+i;j<=n;j+=i) st[j]=true;
}
}
}
signed main()
{
is_prime(1e6);
int n;
while(cin>>n&&n)
{
memset(cnt,0,sizeof(cnt));
for(int i=0;prime[i]<=n;i++)
{
cnt[i]=0;
int tmp=n;
while(tmp)
{
cnt[i]+=tmp/prime[i];
tmp/=prime[i];
}
}
int ans=1;
for(int i=0;prime[i]<=n;i++)
{
if(cnt[i]>0)
{
ans=(ans%mod*((cnt[i]+1)*(cnt[i]+2)/2)%mod)%mod;
}
}
printf("%lld\n",ans);
}
return 0;
}
边栏推荐
- Those things I didn't know until I took the postgraduate entrance examination
- PHP5下WSDL,SOAP调用实现过程
- LeetCode_69(x 的平方根 )
- Sqllab 1-6 exercise
- 常见问题之PHP——Fatal error: Allowed memory size of 314572800 bytes exhausted...
- leetcode 10. Regular expression matching regular expression matching (difficult)
- Deep copy is hard
- LeetCode_2(两数相加)
- 2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
- 神经网络物联网未来现状和趋势及看法
猜你喜欢
TDengine 社区问题双周精选 | 第三期
基于微信小程序的订餐系统
Attack and defense world web WP
基于 TiDB 场景式技术架构过程 - 理论篇
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
Recommendation number | what are interesting people looking at?
Comparison of several distributed databases
[js] basic syntax - for loop
Why do I support bat to dismantle "AI research institute"
[cloud resources] what software is good for cloud resource security management? Why?
随机推荐
::ffff:192.168.31.101 是一个什么地址?
3W原则[通俗易懂]
深拷贝真难
Selenium crawls Baidu pictures
ETCD数据库源码分析——rawnode简单封装
Detailed explanation of SSH password free login
蓝桥杯学习2022.7.5(上午)
广发期货排名多少?网上办理广发期货开户安全可靠吗?
LeetCode_2(两数相加)
Kafaka log collection
Pancake Bulldog robot V2 (code optimized)
POI set the data format of the column (valid)
Ueditor + PHP enables Alibaba cloud OSS upload
NFT value and white paper acquisition
基于伯努利原理的速度监测芯片可用于天然气管道泄露检测
IP packet header analysis and static routing
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
-Web direction attack and defense world
如何把大的‘tar‘存档文件分割成特定大小的多个文件
Requests + BS4 crawl Douban top250 movie information