#include #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3f #define EPS (1e-10) #define rep(i,n)for(int i=0;iP; int dp[20001]; bool is_prime[20001]; int prime[2000]; int main() { memset(is_prime, 1, sizeof(is_prime)); memset(dp, -1, sizeof(dp)); is_prime[0] = is_prime[1] = false; int p = 0; int n; scanf("%d", &n); for (int i = 2; i <= n; i++) { if (is_prime[i]) { prime[p++] = i; for (int j = i * 2; j <= n; j += i)is_prime[j] = false; } } dp[0] = 0; rep(i, p) { for (int j = n - prime[i]; j >= 0; j--) { if (~dp[j])dp[j + prime[i]] = max(dp[j + prime[i]], dp[j] + 1); } } printf("%d\n", dp[n]); }