結果

問題 No.36 素数が嫌い!
ユーザー tadanoningen
提出日時 2020-09-24 12:42:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 64,128 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-06-28 04:52:07
合計ジャッジ時間 12,462 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 6 WA * 4 TLE * 2 -- * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool is_prime(long long int)':
main.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^

ソースコード

diff #

#include<iostream>
#define ll long long

using namespace std;

bool is_prime(ll n){
    if(n == 1) return true;
    if(n == 2 || n == 3 || n == 5){
        return true;
    }
    
    if(n % 2 ==0 || n % 3 == 0 || n % 5 ==0){
        return false;
    }
    
    for(ll i=7;i <= n;i+=2){
        if(i == n) return true;
        else if(n % i == 0 && n != i) return false;
    }
}

int main(){
    ll n;
    cin >> n;
    if(is_prime(n)) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}
0