Đăng nhập để hỏi chi tiết


Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
JoonHae
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll nmax = 1e6;
map <ll, ll> dp;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
ll n;
while(cin>>n)
{
for(int i = 2; i <= n; i++)
{
ll t = i;
for(int j = 2; j <= sqrt(t); j++)
{
while(t % j == 0)
{
dp[j]++;
t /= j;
}
}
if(t > 1)
{
dp[t]++;
}
}
for(int i = 0; i < dp.size(); i++)
{
if(dp[i] != 0)
{
cout<<dp[i]<<" ";
}
}
cout<<"\n";
dp.clear();
}
}Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin