Hdoj find new friends _ water problem

Source: Internet
Author: User
Tags time limit
Find a new friend time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9382 accepted Submission (s): 4969


Problem Description The New Year is coming, "Pig Head Help Association" ready to engage in a party, already know the existing member N people, the membership from 1 to n number, where the president's number is N, and the president is an old friend, then the member's number affirmation and n have more than 1 of the convention number, otherwise are new friends , now the president wants to know how many new friends there are. Please compile the program gang length to calculate it.
Input the first line is the number of test data of the group CN (case number,1<cn<10000), followed by the CN line positive integer n (1<n<32768), indicating the number of members.
Output for each n, the number of new friends out of a row, so that a total of CN line output.

Sample Input
2 25608 24027
Sample Output
7680 16016
Author Smallbeer (CML)
Source Hangzhou Electronic ACM Team Training Competition (VII)
Recommend the most conventional Euler function, do not make redundant explanations, in Baidu find the most concise function template.
#include <stdio.h> 
int n,t;
int ou (int n)
{
	int ret=1,i;
	for (i=2;i*i<=n;i++)
	{
		if (n%i==0)
		{
			n=n/i;
			RET =ret* (i-1);
			while (n%i==0)
			{
				n=n/i;
				Ret=ret*i
	}
	}} if (n>1) return
	ret* (n-1);
	else return
	ret;
	
}
int main ()
{
	scanf ("%d", &t);
	while (t--)
	{
		scanf ("%d", &n);
		printf ("%d\n", OU (n));
		
	}
	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.