結果

問題 No.3035 2018
ユーザー mtsdmtsd
提出日時 2018-04-02 13:57:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,541 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 77,904 KB
実行使用メモリ 28,644 KB
最終ジャッジ日時 2023-09-08 13:22:51
合計ジャッジ時間 3,141 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
28,156 KB
testcase_01 AC 171 ms
27,952 KB
testcase_02 AC 174 ms
28,644 KB
testcase_03 AC 173 ms
27,372 KB
testcase_04 AC 173 ms
27,708 KB
testcase_05 AC 170 ms
28,568 KB
testcase_06 AC 173 ms
27,816 KB
testcase_07 AC 172 ms
27,588 KB
testcase_08 AC 171 ms
27,388 KB
testcase_09 AC 171 ms
27,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define N 5000000
vector<ll> prime;
long long  mod = 1000000007;
bool arr[N];
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < N; i++){
		if(arr[i]){
            prime.push_back((ll)i);
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

}
int main(){
    Eratosthenes();
    int n;
    cin >> n;
    vector<ll>v;
    //cout << prime[prime.size()-1] << endl;
    ll s = 2* prime[prime.size()-1];
    for(int i=0;i<prime.size();i++){
        if(i==0){
            for(int j=1;j<prime.size();j++){
                v.PB(prime[0]*prime[j]);
            }
            
        }else{
            for(int j=i+1;j<prime.size();j++){
                if(prime[i]*prime[j]>s)break;
                v.PB(prime[i]*prime[j]);
            }
        }
    }
    for(int i=0;i<prime.size();i++){
        if(prime[i]*prime[i]*prime[i]>s)break;
        v.PB(prime[i]*prime[i]*prime[i]);
    }
    sort(v.begin(),v.end());
    cout << v[n-1] << endl;
    return 0;
}

0