第2个回答 2012-05-26
#include <stdio.h>
int isprime(int n)
{
int i;
if(n<2)
{
return 0;
}
for(i=2;i*i<=n;++i)
{
if(n%i==0)
{
return 0;
}
}
return 1;
}
long get_out(long m,int n)
{
long temp,result=0L,weight=1L;
while(n)
{
temp=m*(n%10)*weight%1000000L;
result+=temp;
result%=1000000L;
n/=10;
weight*=10L;
}
return result;
}
int main()
{
int t,i,j,in;
long out[20];
scanf("%d",&t);
for(i=0;i<t;++i)
{
scanf("%d",&in);
out[i]=1L;
for(j=2;j<=in;++j)
{
if(isprime(j))
{
out[i]=get_out(out[i],j);
}
}
}
for(i=0;i<t;++i)
{
printf("%ld\n",out[i]);
}
return 0;
}本回答被提问者采纳
第4个回答 2012-05-27
#include <stdio.h>
int isprime(int n)
{
int i;
if(n<2)
{
return 0;
}
for(i=2;i*i<=n;++i)
{
if(n%i==0)
{
return 0;
}
}
return 1;
}
long get_out(long m,int n)
{
long temp,result=0L,weight=1L;
whil
temp=m*(n%10)*weight%1000000L;
result+=temp;
result%=1000000L;
n/=10;
weight*=10L
return result
int main
int t,i,j,in;
long out[20];
scanf("%d",&t);
for(i=0;i<t;++i)
scanf("%d",&in);
out[i]=1L;
for(j=2;j<=in;++j)
if(isprime(j))
out[i]=get_out(out[i],j);
printf("%ld\n",out[i]);
}
return 0;
}