Uva 967 - Circular
#include<bits/stdc++.h>
using namespace std;
#define mx4 1000100
long long circular[]={2,3,5,7,11,13,17,31,37,71,73,79,97,113,131,197,199,311,337,373,719,733,
919, 971, 991, 1193, 1931, 3119, 3779, 7793,7937, 9311,9377, 11939, 19391,19937,37199,39119,
71993,91193,93719,93911,99371,193939,199933,319993,331999,391939,
393919,919393,933199,939193,939391,993319,999331};
int main()
{
long long a,b;
//cout << sizeof(circular);
while(cin >> a)
{
if(a<0)
{
break;
}
cin >> b;
int cnt=0;
for(int i=0;i<55;i++)
{
if(circular[i] > b)
{
break;
}
if(circular[i]>=a and circular[i]<=b)
{
cnt++;
}
}
if(cnt)
{
if(cnt==1)
{
cout << cnt << " Circular Prime.\n";
}
else
{
cout << cnt << " Circular Primes.\n";
}
}
else
{
cout << "No Circular Primes.\n";
}
}
return 0;
}
using namespace std;
#define mx4 1000100
long long circular[]={2,3,5,7,11,13,17,31,37,71,73,79,97,113,131,197,199,311,337,373,719,733,
919, 971, 991, 1193, 1931, 3119, 3779, 7793,7937, 9311,9377, 11939, 19391,19937,37199,39119,
71993,91193,93719,93911,99371,193939,199933,319993,331999,391939,
393919,919393,933199,939193,939391,993319,999331};
int main()
{
long long a,b;
//cout << sizeof(circular);
while(cin >> a)
{
if(a<0)
{
break;
}
cin >> b;
int cnt=0;
for(int i=0;i<55;i++)
{
if(circular[i] > b)
{
break;
}
if(circular[i]>=a and circular[i]<=b)
{
cnt++;
}
}
if(cnt)
{
if(cnt==1)
{
cout << cnt << " Circular Prime.\n";
}
else
{
cout << cnt << " Circular Primes.\n";
}
}
else
{
cout << "No Circular Primes.\n";
}
}
return 0;
}
Comments
Post a Comment