F-Find new friends
The new Year is coming, "Pig Head Help Association" ready to engage in a party, already know the existing member N, the member from 1 to n number, the president of the number is N, and the president is an old friend, then the member's number affirmation and N has more than 1 of the convention number, otherwise are new friends, now the president would like to know how Please make up the program gang length calculation.
Input
The first line is the number of groups of test data cn (case number,1<cn<10000), followed by a CN-line positive integer n (1<n<32768), representing the number of members.
Output
For each n, the number of new friends is output, so there is a CN line output.
Sample Input
2
25608
24027
Sample Output
7680
16016
#include <stdio.h>
#include <string.h>
#include <cstring>
#define MAX 32768
int A[max];
int main ()
{
int n,m,sum;
scanf ("%d", &n);
while (n--)
{
scanf ("%d", &m);
sum=0;
memset (A,0,sizeof (a));//Array zeroing
int i,j;
for (i=2;i<=m/2;i++)
{
if (m%i==0)
{
for (j=i;j<m;j+=i)//There is a minimum number of conventions to save 1
A[j]=1;
}
}
for (i=2;i<m;i++)
{
if (a[i]==0)//Not 1 is a new friend
sum++;
}
printf ("%d\n", sum+1);
}
return 0;
}