#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include #define ll long long #define ull unsigned long long #define pii pair #define pp pair,pair> #define pll pair #define pdd pair #define vii vector #define vll vector #define mat vector> #define lb lower_bound #define ub upper_bound #define pb push_back #define fi first #define sc second #define rep(i,n) for(ll i=0;i=0;i--) #define all(x) x.begin(),x.end() #define sz(x) (ll) (x).size() #define pq priority_queue #define pqg priority_queue,greater> #define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin()) #define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin()) #define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end()) #define int ll using namespace std; const ll INF = (1 << 30 ) - 1; const ll LLINF = (1LL << 60LL); const ll MOD = 1000000007; const ll mod = 998244353; const ll MAX = 1100000; const double pi = acos(-1); const double eps = 1e-10; ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1}; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } struct Timer{ chrono::system_clock::time_point start, end; Timer(){ start = chrono::system_clock::now(); } ~Timer(){ end = chrono::system_clock::now(); auto msec = chrono::duration_cast(end - start).count(); cerr<<"time : "<>n; rep2(i,1,n+1){ if(is_prime(i)) v.pb(i); } ll dp[20010]={}; ll m=v.size(); dp[2]=1; rep2(i,1,m){ repr(j,n+1){ if(dp[j]>0){ chmax(dp[j+v[i]],dp[j]+1); } } chmax(dp[v[i]],1ll); } if(dp[n]==0) cout<<-1<