[恢]hdu 2012

2011-12-12 05:27:32

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2012

题意:中文题。

mark:wa了一次,超2的。自己以为聪明地写了一个预处理,结果忘记把表达式写进去了,IsPrme的参数直接写了个i,太2了。

代码:

# include <stdio.h>


int IsPrime(int n)
{
int i ;
for (i = 2 ; i < n ; i++)
if (n%i==0) break ;
return i >= n ;
}


int main ()
{
int i, tab[100] = {0}, x, y ;
for (i = -39 ; i <= 50 ; i++)
{
tab[i+40] = (!IsPrime(i*i+i+41)) ;
tab[i+40] += tab[i+39] ;
}
while (~scanf ("%d%d", &x, &y) && (x||y))
puts (tab[x+39] == tab[y+40] ? "OK" : "Sorry") ;
return 0 ;
}



posted @ 2012-01-06 14:24  Seraph2012  阅读(214)  评论(0编辑  收藏  举报