杭电ACM 2012

#include<stdio.h>
#include<math.h>

int
main()
{

    int
i, j, n, x, y, t;
    while
(scanf("%d%d",&x,&y)!=EOF)
    {
   
        if
(x==0&&y==0)
        {

            continue
;
        }

        j=0;
        for
(i=x;i<=y;i++)
        {

            t=i*i+i+41;

                for
(n=2;n<=sqrt(t);n++)
                {

                    if
(t%n==0)
                    {

                        j+=1;
                        break
;
                    }

                    else

                    {

                        j=j;
                    }
               
                }
           
           
            }

            if
(j==0)
            {

                printf("OK\n");
               
            }

            else

            {

                printf("Sorry\n");
            }
       
   
    }



    return
0;
}

posted on 2013-03-16 17:39  facetosea  阅读(148)  评论(0编辑  收藏  举报

导航