早教吧 育儿知识 作业答案 考试题库 百科 知识分享

为什么输入10000就不行了,ProblemDescriptionThere'sasequence{An}.An>=0foralln>=0.Andwehavetheequation:An=An*An-An*An-1-2*An-1*An-1-An-1.AndA0=1.Nowyouaregivenanintegern,andyouneedtotellhowmuchisAn%1

题目详情
为什么输入10000就不行了,
Problem Description
There's a sequence { An }.An >= 0 for all n>=0.And we have the equation:An = An*An - An*An-1 - 2 * An-1 * An-1 - An-1.And A0= 1.Now you are given an integer n,and you need to tell how much is An % 100007.
Input
An integer T indicates the number of test cases.T lines followed.Each line contains an integer n.(0
▼优质解答
答案和解析
1、
#include
using namespace std;
#include
void f(int n)
{
int i,j=0,k,xx[100];
for(i=2;i if(n%i==0)
{
j++;xx[j]=i;
}
xx[0]=1;
xx[j+1]=n;

if(n==0||n<0) cout<<"数据错误!"< else if(n==1) cout<<"这个数非素数!"< else
{
if(j==0)
cout<<"这个数是素数!"< else
{
cout<<"这个数非素数!"< cout<<"它的所有因数依次为:"< for(k=0;k<=j+1;k++)
cout< cout< }
}
}
int main()
{
int n;
cout<<"请输入要检验的整数:"< cin>>n;
f(n);
return 0;
}
2、
#include
#include
using namespace std;
#define N 10000
int f(int n)
{
int i,j=0;
for(i=2;i<=sqrt(n);i++)
if(n%i==0)
j++;
if(n==1) return 0;
else
{
if(j==0)
return 1;
else
return 0;
}
}
int main()
{
int i,sum=0;
for(i=1;i<=N;i++)
if(f(i))
{
sum+=i;

}
cout< return 0;
}