杭电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;
}

你可能感兴趣的:(2012)