Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3481 | liumingxuan | 合数求和 | C++ | 通过 | 0 MS | 252 KB | 403 | 2023-01-08 14:37:54 |
#include<bits/stdc++.h> using namespace std; bool v[200]; int a[200]; int main(){ int n; cin>>n; for(int i=2;i<=n;i++){ if(!v[i])a[++a[0]]=i; for(int j=1;j<=a[0]&&i*a[j]<=100;j++) v[i*a[j]]=true; } int sum=0; for(int i=1;i<=n;i++)if(v[i])sum+=i; cout<<sum; return 0; } /* #include<cstdio> freopen("文件名.in","r",stdin); freopen("文件名.out","w",stdout); */