提交时间:2021-05-27 21:21:35

运行 ID: 19998

#include<iostream> #include<cstdio> using namespace std; int a[10005]; int check(int x) { int i; if (x<2) return 0; for (i=2;i*i<=x;++i) if (x%i==0) return 0; return 1; } int main() { int i,n,len=0,ans=0; cin>>n; for (i=2;i<=n;++i) if (check(i)){ ++len; a[len]=i+len; } for (i=1;i<=len;++i) if (check(a[i])) ans+=a[i]; ans=ans%(n+1); cout<<ans; return 0; }