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

WHY WRONG ANSWER HELP ME!
Posted by TRTR 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;

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