CodePudding user response:
Send technical area, otherwise people can't see,CodePudding user response:
Many methods, if m is prime sieve method can be used for primeM large loop only judge whether a prime, then sum
CodePudding user response:
Erichsen sieve method# include
# define ll long long
using namespace std;
E5 const int maxn=1 + 5;
Int vis [maxn];
Int main () {
Int j, ans=0;
The scanf (" % d ", & amp; M);
For (int I=2; i<=m; + + I) {
If (vis [I]==0) ans +=I;
For (int j=I + I; j<=m; J +=I)
Vis [j]=1;
}
Printf (" % d \ n ", ans);
return 0;
}