結果

問題 No.3035 2018
ユーザー chocoruskchocorusk
提出日時 2019-04-01 04:01:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 101,828 KB
実行使用メモリ 29,236 KB
最終ジャッジ日時 2023-08-15 19:24:26
合計ジャッジ時間 3,436 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
27,972 KB
testcase_01 AC 156 ms
27,720 KB
testcase_02 AC 159 ms
28,912 KB
testcase_03 AC 160 ms
27,392 KB
testcase_04 AC 161 ms
28,924 KB
testcase_05 AC 158 ms
27,216 KB
testcase_06 AC 158 ms
27,444 KB
testcase_07 AC 162 ms
29,236 KB
testcase_08 AC 160 ms
28,144 KB
testcase_09 AC 160 ms
27,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const int MAX=5000000;
vector<ll> prime;
bool isprime[MAX];
void sieve(){
	for(ll i=3; i<MAX; i+=2){
		isprime[i]=1;
	}
	isprime[2]=1;
	prime.push_back(2);
	for(ll i=3; i<MAX; i++){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=2*i; j<MAX; j+=i){
				isprime[j]=0;
			}
		}
	}
	return;
}
int main()
{
    sieve();
    vector<ll> ans;
    for(int i=0; i<prime.size(); i++){
        ll p=prime[i];
        for(int j=i+1; (j<prime.size() && prime[j]*p<=1e7); j++){
            ll q=prime[j];
            ans.push_back(p*q);
        }
    }
    for(int i=0; i<prime.size(); i++){
        ll p=prime[i];
        ll x=p*p*p;
        if(x>1e7) break;
        ans.push_back(x);
    }
    sort(ans.begin(), ans.end());
    int n; cin>>n;
    cout<<ans[n-1]<<endl;
    return 0;
}
0