#include #include using namespace std; /* dp[i]は、整数iの素数での和の数のmax */ int dp[40001]; vector makeBitPrimes(int n){ vector v(n+1, 1); v[0] = v[1] = 0; for(int i = 2; i*i <= n; i++){ if(v[i]==1){ int j = i + i; while (j <= n){ v[j] = 0; j = j + i; } } } return v; } int main(void){ // Your code here! int N; vector v = makeBitPrimes(40000); cin >> N; for(int i = 0; i <= 40000; i++) { dp[i] = -1; } dp[0] = 0; for(int i = 1; i <= 20000; i++){ if(v[i] == 0) continue; for(int j = N; j >= 0; j--){ if(i+j <= N && dp[j] != -1) dp[i+j] = max(dp[i+j], dp[j] +1); } } cout << dp[N] << endl; }