UVa Problem 10006 카 르 미 카 엘 번호 (카 르 미 카 엘 수)
// Carmichael Numbers (Carmichael  )
// PC/UVa IDs: 110702/10006, Popularity: A, Success rate: average Level: 2
// Verdict: Accepted
// Submission Date: 2011-06-10
// UVa Run Time: 0.336s
//
//     (C)2011,  。metaphysis # yeah dot net
//
//             x^y mod n = (x mod n)^y mod n。                
// Carmichael     ,            !         ,    
// (x mod n) ^ y mod n = ((x mod n) ^ (y / 2) mod n) * ((x mod n) ^ (y / 2)
//  mod n) * ((x mod n) ^ (y % 2) mod n) mod n,      ,    TLE。
#include <iostream>
#include <cmath>
using namespace std;
#define CAPACITY 15
void print(int n, bool normal)
{
	if (normal)
		cout << n << " is normal." << endl;
	else
		cout << "The number " << n << " is a Carmichael number." << endl;
}
int main(int ac, char *av[])
{
	int n;
	int array[CAPACITY] =
		{ 561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341,
			41041, 46657, 52633, 62745, 63973 };
	while (cin >> n, n)
	{
		bool normal = true;
		for (int c = 0; c < CAPACITY; c++)
			if (array[c] == n)
			{
				normal = false;
				break;
			}
		print(n, normal);
	}
	return 0;
}이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Docker를 사용한 React 및 .NET Core 6.0 샘플 프로젝트 - 1부이 기사에서는 Entity Framework Core Code First 접근 방식을 사용하는 ASP.NET Core 6.0 WEP API의 CRUD(만들기, 읽기, 업데이트 및 삭제) 작업에 대해 설명합니다. 웹 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.