#include<iostream> using namespace std; int Judge(int n){ /*if(n==1){ return 0; } else*/ //省去无效计算 for(int i=2;i*i<=n;i++){ if(n%i==0){ return 0; } } return 1; } int main(){ int n,sum=0; cin>>n; for(int i=2;i<=n;i++){ sum+=Judge(i); } cout<<sum; return 0; }
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 追梦算法网 universal account