結果
| 問題 | No.1058 素敵な数 |
| コンテスト | |
| ユーザー |
onsen_manjuuu
|
| 提出日時 | 2020-06-16 15:18:16 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 848 bytes |
| 記録 | |
| コンパイル時間 | 1,242 ms |
| コンパイル使用メモリ | 191,020 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-20 00:58:43 |
| 合計ジャッジ時間 | 2,006 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:11: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >]', declared with attribute 'nodiscard' [-Wunused-result]
33 | unique(a.begin(), a.end());
| ~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
875 | unique(_ForwardIterator __first, _ForwardIterator __last)
| ^~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> divisor(ll n){
vector<ll> res;
for(ll i = 1LL; i * i <= n; i++){
if(n % i == 0){
res.push_back(i);
ll j = n / i;
if(i != j)res.push_back(j);
}
}
sort(res.begin(),res.end());
return res;
}
int main()
{
vector<ll> prime;
for(int i = 100001; prime.size() <= 100; i++) {
if(divisor(i).size() == 2)prime.push_back(i);
}
vector<ll> a;
int m = prime.size();
for(int i = 0; i < m; i++) {
for(int j = 0; j < m; j++) {
a.emplace_back(prime[i] * prime[j]);
}
}
sort(a.begin(), a.end());
unique(a.begin(), a.end());
int n; cin >> n;
if(n == 1) {
cout << 1 << endl;
} else {
cout << a[n - 2] << endl;
}
}
onsen_manjuuu