結果

問題 No.192 合成数
ユーザー Kou0406
提出日時 2025-03-21 10:05:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 65,040 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-21 10:05:20
合計ジャッジ時間 2,495 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

#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