Pages

মঙ্গলবার, ৩০ এপ্রিল, ২০১৩

uva solution Less prime 10852

provlem link
solution:
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    int n,x,i,check,test_case;
    cin>>test_case;
    while(test_case--)
    {
        cin>>n;
        for(i=2;i<=n;i++)
        {
            check=1;
            for(int j=2;j<=sqrt(i);j++)
            {
                if(i%j==0)
                {
                    check=0;
                     break;
                }
            }
            if(check==1)
            {
               if(i<=n&&(i*2)>n)
               {
                  printf("%d\n",i);
                  break;
               }
            }
        }
    }
 return 0;
}


0 comments:

একটি মন্তব্য পোস্ট করুন