// 基本テンプレート #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define debug(...) fprintf(stderr, __VA_ARGS__) #define int long long int template void chmax(T &a, T b) {a = max(a, b);} template void chmin(T &a, T b) {a = min(a, b);} template void chadd(T &a, T b) {a = a + b;} typedef pair pii; typedef long long ll; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const ll INF = 1001001001001001LL; const ll MOD = 1000000007LL; const int S = 2000000; bool is_prime[S+10]; int K; signed main() { memset(is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false; for(int i=2; i<=S; i++) { if(!is_prime[i]) continue; // printf("prime: %lld\n", i); for(int k=2*i; k<=S; k+=i) { is_prime[k] = false; } } cin >> K; if(K == 0) { cout << 1 << endl << 4 << endl; return 0; } vector ans; int A = 1; while(A*(A-1) / 2 <= K) A++; A--; for(int i=0; i1; i+=2) { if(is_prime[i+X] && !is_prime[i+Y]) { K -= 2; ans.push_back(i); } } for(int i=3; K>0; i+=2) { if(!is_prime[i+X] && is_prime[i+Y]) { K--; ans.push_back(i); } } cout << ans.size() << endl; for(size_t k=0; k 250) continue; printf("A = %lld, B = %lld\n", A, B); vector ans; for(int k=0; k