結果
問題 |
No.308 素数は通れません
|
ユーザー |
![]() |
提出日時 | 2015-12-01 04:19:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 884 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 85,548 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-14 06:30:33 |
合計ジャッジ時間 | 5,817 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 90 TLE * 1 -- * 16 |
ソースコード
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<climits> #include<iostream> #include<string> #include<vector> #include<map> #include<queue> #include<deque> #include<algorithm> #include<utility> #include<complex> #include<functional> #include<cassert> #include<set> #include<stack> using namespace std; typedef long long ll; bool isPrime(ll n){ for(int i=2;i<=sqrt(n);i++){ if(n%i==0) return false; } return true; } void solve(){ ll n; cin >> n; if(n==4) cout << 3 <<endl; else if(n==6) cout << 5 <<endl; else if(n==8||n==9||n==10||n==15||n==16||n==22) cout << 7 <<endl; else if(n==12) cout << 11 <<endl; else if(n==14||n==15) cout << 13 <<endl; else if(n==20||n==21) cout << 19 <<endl; else if(n==24||n==25) cout << 23 <<endl; else if(n%8==1&&isPrime(n-8)) cout << 14 <<endl; else cout << 8 <<endl; } int main(){ solve(); return 0; }