codeforces 1129B wrong anwser【构造】
题目大意
求(最大连续子序列和*长度 )- (最大连续子序列和)=k
给出k,构造序列
题目分析
令第一项为-1 ,
两者的差变为
n∗s−(n−1)∗(s+1)=s−n+1=k
构造这样的序列即可
然而构造的时候,因为细节不够想清楚,上演了一个悲伤的故事
代码
#include <bits/stdc++.h>
#define cl(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
#define fi first
#define se second
using namespace std;
const int mod=1e9+7;
typedef long long ll;
const int maxn=1e6;
const int inf=0x3f3f3f3f;
typedef pair<int,int>PII;
ll fpow(ll n,ll k,ll p=mod){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
ll inv(ll n,ll p=mod){return fpow(n,p-2,p);}
ll fact[maxn];
void init(ll p = mod){fact[0]=1;rep(i,1,maxn-1)fact[i]=fact[i-1]*i%p;}
ll C(ll n,ll m,ll p=mod){return fact[n]*inv(fact[m])%p*inv(fact[n-m])%p;}
ll n;
int main()
{
cin>>n;
ll r = n%maxn;
ll p = n/maxn;
ll cnt=r?p+2:p+1;
if(r+cnt-1>=maxn) cnt = p+3;
else cnt=p+2;
cout<<cnt<<endl;
ll s = n+cnt;
p = s/maxn;
r = s%maxn;
cout<<-1<<" ";
for(int i=1;i<=p;i++)
{
cout<<maxn<<" ";
}
if(r) cout<<r<<endl;
return 0;
}