Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
24531 LeoWang 合数求和 C++ 通过 0 MS 248 KB 348 2023-08-14 02:18:46

Tests(1/1):


#include<bits/stdc++.h> using namespace std; bool heshu(int a){ int cnt=0; for(int i=1;i<a;i++){ if(a%i==0){ cnt++; } } if(cnt==1){ return false; } else{ return true; } } int main() { int N; cin>>N; int sum=0; for(int i=4;i<=N;i++){ if(heshu(i)==true){ sum+=i; } } cout<<sum; return 0; }


测评信息: