cf1130E. Wrong Answer(构造)
程序员文章站
2022-05-14 09:42:07
题意 "题目链接" Sol 对构造一无所知。。。 题解的方法比较神仙,,设第一个位置为$ 1$,$S = \sum_{i=1}^n a_i$ 那么我们要让$N S (N 1) (S + 1) = K$ 固定$N$之后可以直接解出$S$。。。 cpp include define Pair pair ......
题意
sol
对构造一无所知。。。
题解的方法比较神仙,,设第一个位置为\(-1\),\(s = \sum_{i=1}^n a_i\)
那么我们要让\(n * s - (n - 1) * (s + 1) = k\)
固定\(n\)之后可以直接解出\(s\)。。。
#include<bits/stdc++.h> #define pair pair<ll, ll> #define mp(x, y) make_pair(x, y) #define fi first #define se second #define ll long long #define fin(x) {freopen(#x".in","r",stdin);} #define fout(x) {freopen(#x".out","w",stdout);} using namespace std; const int maxn = 2001, mod =666623333, inf = 1e9 + 10; const double eps = 1e-9; template <typename a, typename b> inline bool chmin(a &a, b b){if(a > b) {a = b; return 1;} return 0;} template <typename a, typename b> inline bool chmax(a &a, b b){if(a < b) {a = b; return 1;} return 0;} template <typename a, typename b> inline ll add(a x, b y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;} template <typename a, typename b> inline void add2(a &x, b y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);} template <typename a, typename b> inline ll mul(a x, b y) {return 1ll * x * y % mod;} template <typename a, typename b> inline void mul2(a &x, b y) {x = (1ll * x * y % mod + mod) % mod;} template <typename a> inline void debug(a a){cout << a << '\n';} template <typename a> inline ll sqr(a x){return 1ll * x * x;} inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int n = 2000, a[maxn]; signed main() { a[1] = -1; int lim = 1e6, k = read(), s = k + n; for(int i = 2; i <= n; i++) if(s > lim) a[i] = lim, s -= lim; else {a[i] = s; break;} cout << n << '\n'; for(int i = 1; i <= n; i++) cout << a[i] << " "; return 0; }