示例#1
0
文件: random2.cpp 项目: mohitsh/cpp
int getrand(int min, int max)
{
	srand(static_cast<unsigned int>(time(0)));
	std::random_device rd;
	std::mt19937 mersenne(rd());

	static const double fraction = 1.0/(static_cast<double>(RAND_MAX) + 1.0);
	return static_cast<int>(mersenne()*fraction*(max-min+1)+min);
}
示例#2
0
int main()
{
    int i,n,temp,k;
    int result1=0,result2=0;
    scanf("%d",&n);
    while(n--)
    {
        i=1;
        scanf("%d",&k);
        temp=k;
        while(temp!=1)
        {
            i=mersenne(i);
            while(temp%i==0)
                temp/=i;
        }
        if(i>result2)
        {
            result2=i;
            result1=k;
        }
    }
    printf("%d\n",result1);
    return 0;
}