70分救一下
查看原帖
70分救一下
724021
baojunqian楼主2024/12/21 16:32
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
int n,m,ans;
string s;
bool f[N];
void bao(int n){
    for(int i=2;i<=n;i++){
        if(f[i]==0){
            for(int j=i*i;j<=n;j+=i) f[j]=1;
        }
    }
}
signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    bao(1000000);
    f[1]=1;
    for(int i=1;i<=n;i++){
    	if(f[i]==0){
    		ans+=2;
    	}else{
    		for(int j=1;j<=i/j;j++){
    			if(i%j==0){
    				if(i/j!=j) ans+=2;
    				else ans++;
    			}
    		}
    	}
    }
    
    cout<<ans;
    return 0;
}
2024/12/21 16:32
加载中...