Re: 10006 WA. Help Me!
Posted: Fri Sep 07, 2012 7:51 pm
570 is normal.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
using namespace std;
#define sf scanf
#define pf printf
#define ll long long
#define l long
void isprime();
bool BigMod(int n, int nm);
bool ck[65000], Carmichael_number[65000];
const int N = 65000;
int k;
int main()
{
pf("Accepted\n"); // :D
}
Code: Select all
#include<iostream>
#include<cmath>
#include<cstdio>
int n;
int isPrime(int p)
{
double s;
s=sqrt(p);
for(int i=2;i<s+1;i++)
{
if(p%i==0) return 0;
}
return 1;
}
int isOdd()
{
if(n%2==0) return 0;
return 1;
}
int main()
{
double s;
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(1)
{
int flag=0;
scanf("%d",&n);
if(n==0) break;
if(!isOdd()) flag=1;
else
{
if(isPrime(n))
{
flag=1;
}
s=sqrt(n);
for(int i=3;i<=s+1;i++)
{
if(n%i==0 and isPrime(i))
{
if((n-1)%(i-1)!=0)
{
flag=1;
break;
}
}
}
}
if(flag==1) printf("%d is normal.\n",n);
else printf("The number %d is a Carmichael number.\n",n);
}
//if(flag==0) printf("%d is normal.\n",n);
//else printf("The number %d is a Carmichael number.\n",n);
return 0;
}