ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1352. Mersenne Primes

TRTR WHY WRONG ANSWER HELP ME! [2] // Problem 1352. Mersenne Primes 4 Apr 2007 22:00
#include <iostream.h>
#include <math.h>
int prost(int a)
{
    int kol=0;
    for(int i=2;i<=int (sqrt(a));i++)
    {
        if(a%i==0)
            kol++;
    }
    if(kol==0)
        return 1;
    else
        return 0;
}
int main()
{
    int T,n,kol=0,i=0,p=2;
    cin>>T;
    for(int j=0;j<T;j++)
    {
        cin>>n;
        while(i!=n)
        {
            if((prost(pow(2,p)-1))==1)
            {
                i++;
            }
            if(i==n)
            {
                cout<<p<<' ';
            }
            p++;
        }

    }
    return 0;

}
DixonD (Lviv NU) Re: WHY WRONG ANSWER HELP ME! // Problem 1352. Mersenne Primes 4 Apr 2007 22:59
All Mersenne primes you can find in text of problem...
Good luck!..
Orlangur [KievNU] Why didn't you try sample test? (-) // Problem 1352. Mersenne Primes 5 Apr 2007 11:37