10006 - Carmichael Numbers
Moderator: Board moderators
-
- 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!
-
- New poster
- Posts: 36
- Joined: Sun Mar 18, 2012 8:18 am
Re: 10006 WA. Help Me!
Thank You BrianFry. I Got ACCCCCCCCCCCCCCCC
Re: 10006 WA. Help Me!
Please Help >>>
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 :
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 .....
-
- 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!
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;
}
-
- 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!