對任意乙個數n,d是n的乙個約數,他們可以寫成下列格式
約數個數就轉化為等於每個因子有多少種選法
在int範圍內,約數最多的數有大概1500個約數。
**實現
//先對a1, a2,,...an 分別分解,再套用公式
#include
#include
#include
using
namespace std;
const
int mod =
1e9+7;
unordered_map<
int,
int> table;
int n;
intmain()
}}if(x >
1) table[x]++;
}long
long res =1;
for(
auto i:table)
cout << res << endl;
return0;
}
約數之和等於
//先對a1, a2,,...an 分別分解,再套用公式
#include
#include
#include
using
namespace std;
const
int mod =
1e9+7;
unordered_map<
int,
int> table;
int n;
intmain()
}}if(x >
1) table[x]++;
}long
long res =1;
for(
auto i:table)
res = res * sum % mod;
} cout << res << endl;
return0;
}
AcWing 約數之和 約數和定理
時 空限制 1s 64mb 給定n個正整數ai,請你輸出這些數的乘積的約數之和,答案對109 7取模。第一行包含整數n。接下來n行,每行包含乙個整數ai。輸出乙個整數,表示所給正整數的乘積的約數之和,答案需對109 7取模。1 n 100,1 ai 2 10 9 326 8題意 求出一些數的乘積的約...
約數個數 約數之和
給乙個數n,求它的約數個數 因為n可以唯一分解成質因數的乘積即 n p 1 p 2 p t 所以n的約數c的形式應該是 c p 1 p 2 p t 對於任何兩組不同的 beta 1,beta t 的取值,由算數基本定理得c是不同的,由於 beta i 的取值為 0,1,alpha i 共 alpha...
知識總結 約數個數定理和約數和定理及其證明
據說這倆是小學奧數內容?完了我菜成一團沒上過小學 本文只研究正整數 a a 的約數個數和約數和。首先對 a role presentation style position relative a a分解質因數a inp aii pi是質 數 a inpi ai p i是質數 先看結論 nu m i ...