結果

問題 No.36 素数が嫌い!
ユーザー mosmos_21mosmos_21
提出日時 2018-01-07 12:07:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,646 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 165,192 KB
実行使用メモリ 79,308 KB
最終ジャッジ日時 2023-08-24 23:23:35
合計ジャッジ時間 6,898 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
40,176 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 94 ms
27,920 KB
testcase_12 AC 426 ms
79,108 KB
testcase_13 AC 417 ms
79,308 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 82 ms
34,104 KB
testcase_20 AC 322 ms
79,124 KB
testcase_21 AC 228 ms
62,776 KB
testcase_22 AC 239 ms
64,904 KB
testcase_23 AC 111 ms
40,208 KB
testcase_24 WA -
testcase_25 AC 126 ms
44,352 KB
testcase_26 AC 225 ms
50,552 KB
testcase_27 AC 350 ms
68,884 KB
testcase_28 AC 221 ms
48,444 KB
testcase_29 AC 397 ms
77,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

ll p[10000001] = {};
signed main(){ INIT;
    VAR(ll, n);
    if(n < 3){ NO; RET; }

    p[0] = p[1] = 1;
    ll i = 2;
    while(i < sqrt(n)+2){
        for(ll k = i * 2; k < sqrt(n)+2; k += i) p[k] = 1;
        i++;
        while(i < sqrt(n)+2 && p[i]) i++;
    }
    FOR(i, 2, sqrt(n)+1) if(!(n%i) && p[i]){
        YES; RET;
    }
    NO;
RET;}
0