F. 神秘的超级素数
Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format:
%lld Java class name:
Main
果姐姐非常喜欢素数呀!
突然有一天,根据未知神秘力量的指引,果姐姐想要去发现超级素数!
一个素数n (n > 4 ) 如果是一个超级素数的话,当且仅当n - 4 和 n + 4 都是素数
果姐姐一脸懵逼!
懵逼的果姐姐想要你来帮助她,你的任务很简单:给一个N,发现一个最大的超级素数n满足n <= N
Input
一个整数N (4 < N < 109),输入数据有多组
Output
如果没有满足条件的整数n输出-1,否则输出n
Sample Input
8
Sample Output
7
#include <cstdio>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std ;
const int maxn = 1e4 + 5 ;
int n ;
int main()
{
while( ~scanf( "%d" , &n ) )
{
if( n >= 7 )
printf( "%d\n" , 7 ) ;
else
printf( "%d\n" , -1 ) ;
}
return 0 ;
}
#include <cstdio>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std ;
const int maxn = 1e4 + 5 ;
int n ;
int main()
{
while( ~scanf( "%d" , &n ) )
{
if( n >= 7 )
printf( "%d\n" , 7 ) ;
else
printf( "%d\n" , -1 ) ;
}
return 0 ;
}