杭電OJ 2012 素數判定

2021-08-18 02:09:06 字數 542 閱讀 8564

problem description

對於表示式n^2+n+41,當n在(x,y)範圍內取整數值時(包括x,y)(-39<=x< y<=50),判定該表示式的值是否都為素數。

input

輸入資料有多組,每組佔一行,由兩個整數x,y組成,當x=0,y=0時,表示輸入結束,該行不做處理。

output

對於每個給定範圍內的取值,如果表示式的值都為素數,則輸出」ok」,否則請輸出「sorry」,每組輸出佔一行。

sample input

0 1

0 0sample output

ok

#include

#include

int sushu(int n)

int main()

}n = y - x + 1;

if (count == n)

printf("ok\n");

else

printf("sorry\n");

}return

0;}

素數判定(杭電2012)

problem description 對於表示式n 2 n 41,當n在 x,y 範圍內取整數值時 包括x,y 39 x input 輸入資料有多組,每組佔一行,由兩個整數x,y組成,當x 0,y 0時,表示輸入結束,該行不做處理。output 對於每個給定範圍內的取值,如果表示式的值都為素數,則...

2012杭電 素數判定

problem description 對於表示式n 2 n 41,當n在 x,y 範圍內取整數值時 包括x,y 39 x input 輸入資料有多組,每組佔一行,由兩個整數x,y組成,當x 0,y 0時,表示輸入結束,該行不做處理。output 對於每個給定範圍內的取值,如果表示式的值都為素數,則...

杭電2012 素數判定

problem description 對於表示式n 2 n 41,當n在 x,y 範圍內取整數值時 包括x,y 39 xinput 輸入資料有多組,每組佔一行,由兩個整數x,y組成,當x 0,y 0時,表示輸入結束,該行不做處理。output 對於每個給定範圍內的取值,如果表示式的值都為素數,則輸...