The League of Sequence Designers(构造)
Posted Harris-H
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The League of Sequence Designers(构造)相关的知识,希望对你有一定的参考价值。
The League of Sequence Designers(构造)
给定的算法就是连续最大子段和,而题意要求 m a x l e n × s u m max\\len\\times sum\\ maxlen×sum
考虑次优值的
s
u
m
=
x
sum=x
sum=x,最优值的
s
u
m
=
x
−
1
sum=x-1
sum=x−1,就是左边多个
−
1
-1
−1。
(
x
−
1
)
×
l
e
n
−
x
×
(
l
e
n
−
1
)
=
k
x
−
l
e
n
=
k
l
e
n
<
2000
L
≤
l
e
n
=
x
−
k
<
2000
x
−
k
≤
1999
x
≤
k
+
1999
(x-1)\\times len-x\\times (len-1) =k \\\\ x-len=k \\\\ len<2000 \\\\ L\\le len=x-k<2000 \\\\ x-k\\le 1999 \\\\ x\\le k+1999
(x−1)×len−x×(len−1)=kx−len=klen<2000L≤len=x−k<2000x−k≤1999x≤k+1999
因为要求
∣
a
i
∣
≤
1
0
6
|a_i|\\le 10^6
∣ai∣≤106,因为要求
l
e
n
≥
L
len\\ge L
len≥L,不妨
l
e
n
=
1999
len=1999
len=1999
这样
x
=
k
+
1999
x=k+1999
x=k+1999
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
const int hashmod[4] = 402653189,805306457,1610612741,998244353;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define x first
#define y second
#define pb emplace_back
#define SZ(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define ios ios::sync_with_stdio(false),cin.tie(nullptr)
void Print(int *a,int n)
for(int i=1;i<n;i++)
printf("%d ",a[i]);
printf("%d\\n",a[n]);
template <typename T> //x=max(x,y) x=min(x,y)
void cmx(T &x,T y)
if(x<y) x=y;
template <typename T>
void cmn(T &x,T y)
if(x>y) x=y;
int main()
int t,k,l;scanf("%d",&t);
while(t--)
scanf("%d%d",&k,&l);
if(l>=2e3)
puts("-1");continue;
int n=2e3-1;
printf("%d\\n-1",n);
ll x=n+k;
ll ave = x/(n-1),rest = x%(n-1);
rep(i,2,n-1)
printf(" %d",ave);
printf(" %d\\n",ave+rest);
return 0;
以上是关于The League of Sequence Designers(构造)的主要内容,如果未能解决你的问题,请参考以下文章
2018-3 video sequence ( find the list of size of the each sub sequence )
the arithmetic sequence of integers
数列极差问题(the problem of sequence biggest difference)
Differential Evolution: A Survey of the State-of-the-Art
translation of the paper sequence and structure conservation in a protein core