結果

問題 No.8035 2018
コンテスト
ユーザー ats5515
提出日時 2018-04-01 23:38:27
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 930 ms / 2,000 ms
コード長 1,218 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 541 ms
コンパイル使用メモリ 105,152 KB
実行使用メモリ 12,412 KB
最終ジャッジ日時 2026-03-12 21:00:27
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; ++i)
		primes[i] = i;
	for (int i = 2; i*i < n; ++i)
		if (primes[i])
			for (int j = i*i; j < n; j += i)
				primes[j] = 0;
	vector<int> res;
	for (int i = 2; i < primes.size(); i++) {
		if (primes[i] == i)res.push_back(i);
	}
	return res;
}
vector<int> primes;
int cnt(int a) {
	int res = 0;
	int A = a;
	for (int jj = 0; jj < primes.size(); jj++) {
		int j = primes[jj];
		if (j > a)break;
		if (j*j > a)j = a;
		if (a%j == 0) {
			res++;
			if (res > 2)return 0;
			a /= j;
			if (a%j == 0) {
				if (j*j*j == A) {
					return 1;
				}
				return 0;
			}
		}
	}
	if (res == 2) {
		return 1;
	}
	return 0;

}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	primes = sieve_of_eratosthenes(1000000);
	int res = 0;
	int i = 0;
	while(res < N){
		res += cnt(i);
		i++;
	}
	/*for (int i = 0; i <= N; i++) {
		res += cnt(i);
	}*/
	cout << i - 1 << endl;
}
0