結果
問題 |
No.8035 2018
|
ユーザー |
![]() |
提出日時 | 2018-04-01 23:38:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 795 ms |
コンパイル使用メモリ | 84,908 KB |
実行使用メモリ | 19,084 KB |
最終ジャッジ日時 | 2024-06-26 06:10:07 |
合計ジャッジ時間 | 4,247 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 3 TLE * 1 -- * 3 |
ソースコード
#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; }