結果
| 問題 |
No.1058 素敵な数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-22 21:35:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,031 bytes |
| コンパイル時間 | 1,384 ms |
| コンパイル使用メモリ | 102,756 KB |
| 最終ジャッジ日時 | 2025-01-10 14:28:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 7 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
#include <stack>
#include <math.h>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;
int bsf(ull x) { return __builtin_ctzll(x); }
struct fastset{
int N,lg;
vector<vector<ull>> seg;
fastset(int N):N(N){
while(N>1){
seg.push_back(vector<ull>((N+63)/64));
N=(N+63)/64;
}
lg=seg.size();
}
void ins(int x){
for(int i=0;i<lg;i++){
int D=x/64,R=x%64;
seg[i][D]|=(1ULL<<R);
x/=64;
}
}
void cle(int x){
for(int i=0;i<lg;i++){
int D=x/64,R=x%64;
seg[i][D] &= ~(!1ULL<<R);
if(i&&seg[i-1][x]!=0){
seg[i][D]|=(1ULL<<R);
}
x/=64;
}
}
// x以上の最小の要素
int upp(int x){
for(int i=0;i<lg;i++){
int D=x/64,R=x%64;
if(D==seg[i].size())break;
ull B=seg[i][D]>>R;
if(!B){
x=x/64+1;
continue;
}
// find
x+=bsf(B);
for(int j=i-1;j>=0;j--){
x*=64;
int D=x/64;
x+=bsf(seg[j][D]);
}
return x;
}
return N;
}
};
int N=1000100;
bool isnotprime[1000100];
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
vector<ll> pri;
for(int i=2;i<N;i++){
if(!isnotprime[i]){
if(i>1e5)pri.push_back(i);
for(int j=i+i;j<N;j+=i){
isnotprime[j]=1;
}
}
}
int n; cin >> n;
vector<ll> v;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
v.push_back(pri[i]*pri[j]);
}
}
if(n==1){
printf("1\n");
return 0;
}
sort(v.begin(), v.end());
cout << v[n-2] << endl;
}