小睿睿的数列

小睿睿的数列

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;
}
全部评论

相关推荐

点赞 评论 收藏
分享
07-09 20:50
门头沟学院 Java
码农索隆:1.教育背景和荣誉证书合二为一。 2.获奖项目理一遍,你做了什么,对你求职的岗位有什么帮助,没有就删掉。 3.技能特长和教育背景交换位置。 4.技能特长写的太差,上网上找简历参考。都不用问你别的,一个redis就能把你问住,写写你具体会redis哪些方面的知识。
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务