結果

問題 No.3035 2018
ユーザー ats5515ats5515
提出日時 2018-04-01 23:38:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,218 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 80,268 KB
実行使用メモリ 16,352 KB
最終ジャッジ日時 2023-09-08 12:58:20
合計ジャッジ時間 4,383 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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