2015-Mathematics (2), 2015-mathematics
Description
The New Year is approaching. The pig Association is preparing to have a party. We already know that there are N members and the number of members ranges from 1 to N. The number of the President is N, if you are an old friend of the president, the member's number must have an appointment with N greater than 1. Otherwise, they will all be new friends. Now the president wants to know how many new friends there are? Compile a program to help the President calculate it.
Input
The first line is the number of test data groups CN (Case number, 1 <CN <10000), followed by a positive integer N (1 <n <32768) in CN, indicating the number of members.
Output
For each N, the number of new friends in a row is output, so a total of CN rows are output.
Sample Input
22560824027
Sample Output
768016016
# Include <iostream> # include <cstring> # include <cmath> using namespace std; int a [32778]; int main () {int cn, n, I, j, sum = 0; double k; cin> cn; while (cn --) {sum = 0; memset (a, 0, sizeof (a); cin> n; for (I = 2; I <= n; ++ I) {if (n % I = 0) {for (j = I; j <n; j + = I) {a [j] = 1 ;}}for (I = 2; I <n; ++ I) {if (a [I] = 0) {sum ++ ;}} cout <sum + 1 <endl ;}return 0 ;}