結果

問題 No.1058 素敵な数
ユーザー carrot46carrot46
提出日時 2020-05-22 21:31:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 172,200 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 15:59:29
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    vec prime(0);
    for(ll i = ll(1e+5) + 1; i < 2e+5; ++i){
        bool p = true;
        for(ll j = 2; j * j <= i; ++j){
            if(i%j == 0){
                p = false;
                break;
            }
        }
        if(p){
            prime.push_back(i);
        }
        if(prime.size() == 11) break;
    }
    cin>>N;
    if(N == 1){
        cout<<1<<endl;
    }else{
        vec steki(0);
        rep(i,11){
            rep(j,i + 1){
                steki.push_back(prime[i] * prime[j]);
            }
        }
        sort(ALL(steki));
        cout<<steki[N - 2]<<endl;
    }
}
0