結果
問題 | No.36 素数が嫌い! |
ユーザー |
![]() |
提出日時 | 2018-01-07 12:07:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,646 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 166,164 KB |
実行使用メモリ | 78,848 KB |
最終ジャッジ日時 | 2024-12-23 09:57:12 |
合計ジャッジ時間 | 8,410 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 3 |
ソースコード
#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;}