結果
問題 | No.192 合成数 |
ユーザー | forest3 |
提出日時 | 2020-05-24 14:57:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 470 bytes |
コンパイル時間 | 1,792 ms |
コンパイル使用メモリ | 165,816 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 07:16:10 |
合計ジャッジ時間 | 2,852 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:27:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 27 | cout << ans << endl; | ^~~ main.cpp:20:13: note: 'ans' was declared here 20 | int ans; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; auto IsPrime = []( int num ) -> bool { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; for ( int i = 3; i * i <= num; i += 2 ) { if (num % i == 0) return false; } return true; }; int ans; for( int n = N - 100; n <= N + 100; n++ ) { if( n == 1 || IsPrime( n ) ) continue; ans = n; break; } cout << ans << endl; }