# Zball in Tina Town

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 219    Accepted Submission(s): 144

Problem Description
Tina Town is a friendly place. People there care about each other.

Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes

Input
The first line of input contains an integer

Output
For each test case, output an integer representing the answer.

Sample Input
2
3
10

Sample Output
2
0

 1 /**
2  * code generated by JHelper
4  * @author xyiyy @https://github.com/xyiyy
5  */
6
7 #include <iostream>
8 #include <fstream>
9
10 //#####################
11 //Author:fraud
12 //Blog: http://www.cnblogs.com/fraud/
13 //#####################
15 #include <iostream>
16 #include <sstream>
17 #include <ios>
18 #include <iomanip>
19 #include <functional>
20 #include <algorithm>
21 #include <vector>
22 #include <string>
23 #include <list>
24 #include <queue>
25 #include <deque>
26 #include <stack>
27 #include <set>
28 #include <map>
29 #include <cstdio>
30 #include <cstdlib>
31 #include <cmath>
32 #include <cstring>
33 #include <climits>
34 #include <cctype>
35
36 using namespace std;
37
38 //
39 // Created by xyiyy on 2015/8/7.
40 //
41
42 #ifndef ICPC_SCANNER_HPP
43 #define ICPC_SCANNER_HPP
44
45 #endif //ICPC_SCANNER_HPP
46
47 class hdu5391 {
48 public:
49     void solve(std::istream &in, std::ostream &out) {
50         int t;
51         in >> t;
52         while (t--) {
53             int n;
54             in >> n;
55             if (check(n))out << n - 1 << endl;
56             else if (n == 4)out << 2 << endl;
57             else out << 0 << endl;
58         }
59     }
60
61     bool check(int x) {
62         for (int i = 2; i * i <= x; i++) {
63             if (x % i == 0) {
64                 return 0;
65             }
66         }
67         return 1;
68     }
69 };
70
71 int main() {
72     std::ios::sync_with_stdio(false);
73     std::cin.tie(0);
74     hdu5391 solver;
75     std::istream &in(std::cin);
76     std::ostream &out(std::cout);
77     solver.solve(in, out);
78     return 0;
79 }

posted on 2015-08-16 00:17  xyiyy  阅读(...)  评论(...编辑  收藏

• 随笔 - 102
• 文章 - 0
• 评论 - 7
• 引用 - 0