## 10006 - Carmichael Numbers

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10006 WA. Help Me!

570 is normal.
Check input and AC output for thousands of problems on uDebug!

cse.mehedi
New poster
Posts: 36
Joined: Sun Mar 18, 2012 8:18 am

### Re: 10006 WA. Help Me!

Thank You BrianFry. I Got ACCCCCCCCCCCCCCCC

shuvokr
Learning poster
Posts: 66
Joined: Tue Oct 02, 2012 8:16 pm

### Re: 10006 WA. Help Me!

I don't understand why i get WA, Is my algorithm is wrong ???. If algorithm is ok then need some I/O.
Here is my code :

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
}
``````
Last edited by shuvokr on Mon Apr 01, 2013 11:01 pm, edited 1 time in total.

Code: Select all

``enjoying life ..... ``

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10006 WA. Help Me!

The number 46657 is a Carmichael number.
Check input and AC output for thousands of problems on uDebug!

shuvokr
Learning poster
Posts: 66
Joined: Tue Oct 02, 2012 8:16 pm

### Re: 10006 WA. Help Me!

Code: Select all

``````Thanks brianfry713
``````

Code: Select all

``enjoying life ..... ``

LazyTym
New poster
Posts: 31
Joined: Tue Jun 24, 2014 9:10 pm

### 10006 - Carmichael Numbers Why getting WA!!!!!!!!

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;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10006 - Carmichael Numbers Why getting WA!!!!!!!!

9 is normal.
Check input and AC output for thousands of problems on uDebug!