小睿睿的数列
小睿睿的数列
https://ac.nowcoder.com/acm/contest/6944/A
#include<bits/stdc++.h> typedef long long ll; using namespace std; #define INF 0x3f3f3f3f const int maxn =2e6+5; #define mod 1000000007 using namespace std; const double eps = 1e-6; ll m,a[21],b[300],cnt=0; int main() { int n; ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin>>n; int a[maxn],c[maxn],cnt=0,mi,tem=1; int ma=0; //bool f=1; for (int i=0;i<n;i++) cin>>a[i]; for (int i=0;i<n;i++) { mi=a[i]; tem=i+1; while(tem<n&&(a[tem]%mi==0||mi%a[tem]==0)){if (mi>a[tem]) mi=a[tem];tem++;} if(tem-i+1>ma) {ma=tem-i+1;cnt=1;} else if (tem-i+1==ma) cnt++; i=tem-1; } cout<<cnt<<endl; return 0; }