提交时间:2023-05-27 16:40:38
运行 ID: 74600
#include<bits/stdc++.h> using namespace std; int a[1000010]={0},t[1000010]; int ans=0; int sushu(int o){; for(int i=2;i<=o/i;i++){ if(o%i==0) return 0; } return 1; } int main(){ //freopen("a3.in","r",stdin); //freopen("a3.out","w",stdout); long long n,num=0; cin>>n; for(int i=2;i<=n;i++){ if(i%2==0&&i!=2){ a[i]=a[i-1]+1; ans=max(ans,a[i]); }else{ if(sushu(i)==1) a[i]=0; else a[i]=a[i-1]+1,ans=max(ans,a[i]); } } cout<<ans<<endl; return 0; }