提交时间:2021-05-03 11:12:55
运行 ID: 18977
#include <bits/stdc++.h> using namespace std; long long n,r[1005],a[1005],mi=INT_MAX; void init() { cin>>n>>r[1]; for(int i=1; i<=n; ++i) { a[i]=r[i]%100; r[i+1]=(r[i]*6807+2831)%201701; cout<<a[i]<<' '; } cout<<endl; } int c(int a,int b) { return min(abs(a-b),min(a+(100-b),b+(100-a))); } int main() { init(); for(int i=0;i<=99-n+1;i++) { int s=0; for(int j=1;j<=n;j++)s+=c(i+j-1,a[j]),cout<<c(i+j-1,a[j])<<' '; cout<<endl<<i<<' '<<s<<endl; if(s<mi)mi=s; } cout<<mi*mi<<endl; }