6 solutions
-
0
#这个题可以直接用讲的位运算函数(__builtin_popcount)来解题# ##仅供参考##
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll isprime(ll x) { ll ret=1; if(x==2) ret=1; if(x==1||x==0) ret=0; for(int i=2;i<=sqrt(x);i++) { if(x%i==0) { ret=0; } } return ret; } int main() { ll m,n,k,count=0; cin>>m>>n; for(int i=m;i<=n;i++) { int k=__builtin_popcount(i); if(isprime(k)) { count++; } } cout<<count<<endl; return 0; }
Information
- ID
- 24
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 329
- Accepted
- 99
- Uploaded By