Find new friends (hangdian 1286)

Source: Internet
Author: User

/* Find a new friend
Problem 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
2
25608
24027
 

Sample output
7680
16016

*/
# Include <stdio. h>
Int main ()
{
Int I, a [35000];
Int N, test, J, K;
Scanf ("% d", & test );
While (test --)
{
Int K = 0;
Scanf ("% d", & N );
For (I = 1; I <= N; I ++)
A [I] = I;
For (I = 2; I <= N; I ++)
{
If (N % I = 0)
{
For (j = 1; I * j <n; j ++)
A [I * j] = 0;
}
}
For (I = 1; I <n; I ++)
{
If (A [I]! = 0)
K ++;
}
Printf ("% d \ n", k );
}
Return 0;
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.