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 1086. Cryptography

runtime error
Posted by abir_10t 11 Aug 2016 01:43
#include<stdio.h>
#include<math.h>
int main()
{
    long long int i,n,arr[100000]={0},j,t,a,sum,x;
    arr[0]=1;
    arr[1]=1;
    for(i=2; i<=sqrt(30000); i++)
    {
        if(arr[i]==0)
        {
            for(j=i+i; j<=30000; j=j+i)
            {
                if(arr[j]==0)
                    arr[j]=1;
            }
        }
    }
    scanf("%lld",&t);
    for(i=1; i<=t; i++)
    {

        sum=0;
        scanf("%lld",&a);
        for(j=2; j<=a; j++)
        {
            if(arr[j]==0)
            {
                sum=sum+j;
            }
        }
        x=sum;
        if(sum==n)
        {
            for(sum=x+1; ; sum++)
            {
                if(arr[sum]==0)
                {
                    x=x+sum;
                    break;
                }
            }
            printf("%lld\n",sum);
        }
        else if(sum%2==0)
        {
            for(sum=x+1; ; sum++)
            {
                if(arr[sum]==0)
                {
                    x=x+sum;
                    break;
                }
            }
            printf("%lld\n",sum);

        }
        else
            printf("%lld\n",sum);
    }
    return 0;
}