結果

問題 No.192 合成数
コンテスト
ユーザー Kou0406
提出日時 2025-03-21 10:05:17
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 549 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 332 ms
コンパイル使用メモリ 80,492 KB
実行使用メモリ 9,228 KB
最終ジャッジ日時 2026-07-07 13:50:13
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<cassert>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int n;

int main(){
    int i,j;
    scanf("%d",&n);
    auto isPrime=[](int x)->bool{
        int i;
        if(x==2)return true;
        if(x<=1||x%2==0)return false;
        for(i=3;i<=x/i;i+=2)if(x%i==0)return false;
        return true;
    };
    for(i=max(3,n-100);i<=n+100;i++){
        if(!isPrime(i)){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}
0