NWU_ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include <bits/stdc++.h>
 2 #define INFB 0x3fffffffffffffff
 3 #define INFS 0x3fffffff
 4 #define _xx ios_base::sync_with_stdio(0);cin.tie(0);
 5 using namespace std;
 6 typedef long long ll;
 7 bool isprime(int n)
 8 {
 9     if(n == 2) return true;
10     if(n == 1) return false;
11     for(int i = 2; i*i <= n; i++)
12         if(n%i == 0) return false;
13     return true;
14 }
15 int main()
16 {_xx
17     int n;
18     while(cin >> n)
19     {
20         if(n == 2) cout << 1 << endl;
21         else if(n%2 == 0) cout << 2 << endl;
22         else if(isprime(n)) cout << 1 << endl;
23         else if(isprime(n - 2)) cout << 2 << endl;
24         else cout << 3 << endl;
25     }
26     return 0;
27 }
View Code

 

posted on 2017-05-10 17:44  NWU_ACM  阅读(108)  评论(0编辑  收藏  举报