Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
145426 林泽豪 质数和分解 C++ 通过 100 0 MS 252 KB 390 2024-05-05 08:17:01

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int N=205; bool a[N]; int f[N]; int n; void init (){ for(int i=2;i<=n;i++){ if(a[i]==0){ for(int j=i+i;j<=n;j+=i)a[j]=1; } } } int main(){ cin>>n; init(); f[0]=1; for(int i=2;i<=n;i++){ for(int j=i;j<=n;j++){ if(a[i]==0)f[j]+=f[j-i]; } } //for(int i=0;i<=n;i++)cout<<f[i]<<' '; cout<<f[n]; }


测评信息: