原题目链接:https://begin.lydsy.com/JudgeOnline/problem.php?id=3147
答案
Problem O: 连续非素数的最长度
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 293 Solved: 89
[ Submit][ Status][ Web Board]
Description
给出一个正整数n(2≤n≤1000000),例如n=30,在1,2,3,……30中,连续的非素数有:
4 长度为1
6 长度为1
8 9 10 长度为3
12 长度为1
14 15 16 长度为3
18 长度为1
20 21 22 长度为3
24 25 26 27 28 长度为5
30 长度为1
其中,最大长度为5,即有连续的5个非素数。
4 长度为1
6 长度为1
8 9 10 长度为3
12 长度为1
14 15 16 长度为3
18 长度为1
20 21 22 长度为3
24 25 26 27 28 长度为5
30 长度为1
其中,最大长度为5,即有连续的5个非素数。
Input
一个整数n
Output
一个整数,即连续非素数最大长度
Sample Input
30
Sample Output
5
HINT
#include<bits/stdc++.h>
using namespace std;
long long c[1000001];
bool pri(long long n) {
if(n<2) return false;
for(long long i=2; i*i<=n; i++) {
if(n%i==0) return <