poj2407-Relatives

http://poj.org/problem?id=2407

欧拉函数

 

#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>



using namespace std ;

#define INT __int64



int enlerfun( INT n )

{

	int tempnum = n ;

	for( int i = 2 ; i <= n ; ++i  )

	{

		if( n % i == 0 )

		{

			tempnum -= tempnum / i ;

			while( n % i == 0)

				n /= i ;

		}

	}

	return tempnum ;

}



int main()

{

	INT n ;

	INT count ;

	while( cin >> n && n )

	{

		count = 0 ;

		count = enlerfun( n ) ;

		cout << count << endl ;

	}

	return 0 ;

}


 

 

你可能感兴趣的:(relative)