'commit'
This commit is contained in:
22
TangDou/AcWing_TiGao/T5/FenJieZhiYinShu/197_BruteForce.cpp
Normal file
22
TangDou/AcWing_TiGao/T5/FenJieZhiYinShu/197_BruteForce.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
|
||||
int n;
|
||||
bool prime(int x) {
|
||||
if (x == 2) return 1;
|
||||
for (int i = 2; i * i <= x; i++)
|
||||
if (x % i == 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (!prime(i)) continue;
|
||||
LL x = i;
|
||||
int ans = 0;
|
||||
while (x <= n) ans += n / x, x *= i;
|
||||
printf("%d %d\n", i, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user