結果
| 問題 | No.1058 素敵な数 |
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2020-06-23 15:27:38 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 1,221 ms |
| コンパイル使用メモリ | 190,964 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-20 01:05:16 |
| 合計ジャッジ時間 | 1,801 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:23: 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( ans1.begin(), ans1.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;
bool isPrime( long long x )
{
if( x < 2 ) return false;
if( x == 2 ) return true;
if( x % 2 == 0 ) return false;
for( long long i = 3; i * i <= x; i += 2 ) {
if( x % i == 0 ) return false;
}
return true;
}
int main()
{
int N;
cin >> N;
long long ans = 1;
if( N > 1 ) {
vector<long long> p;
for( long long i = 100000 + 1; p.size() < N; i++ ) {
if( isPrime( i ) ) p.push_back( i );
}
vector<long long> ans1;
for( int i = 0; i < N; i++ ) {
for( int j = 0; j < N; j++ ) {
ans1.push_back( p[i] * p[j] );
}
}
sort( ans1.begin(), ans1.end() );
unique( ans1.begin(), ans1.end() );
ans = ans1[N - 2];
}
cout << ans << endl;
}
forest3