求调(80分)
查看原帖
求调(80分)
1053722
yu_rui楼主2024/5/26 08:59

记录

#include<bits/stdc++.h>
using namespace std;
int p[1000100];
int n,k;
bool check(int x){
    int cow=n-1;
    for(int i=2,j=1;i<=k;++i){
        if(p[i]-p[j]>=x){
            cow--;
            j=i;
            if(cow<=0) return 1;
        }
    }
    return 0;
}
int main(){
    cin>>n>>k>>p[1];
    for(int i=2;i<=k;++i) p[i]=p[i-1]+((p[i-1]*2357+137)%10)+1;
    int l=1,r=p[k],ans=1,mid;
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid)){ ans=mid;l=mid+1;}
        else r=mid-1;
    }
    cout<<ans;
    return 0;
}
2024/5/26 08:59
加载中...